Example of a search with str_detect
Can use grepl or %in% or other tools depending
on what terms you are searching for
#read in possible search terms
library(tidyverse)
## Warning: package 'ggplot2' was built under R version 4.4.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.2 ✔ tibble 3.2.1
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.0.4
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(biomaRt)
data <- read.csv('phenotype_options.csv',header=FALSE)
#define vector of possible terms
result1<-data[str_detect(data$V1, "10-heptadecenoate"), ]
#Select mart
ensembl=useMart("ENSEMBL_MART_SNP",
dataset="hsapiens_snp")
#Select attributes (choose at least 6 related to your search)
att1 <- c('refsnp_id',
'minor_allele',
'minor_allele_freq',
'phenotype_name',
'phenotype_description',
'clinical_significance',
'associated_variant_risk_allele',
'p_value',
'validated')
#Run search
searchResults <-getBM(att1,
filters= 'phenotype_description',
values= result1,
mart=ensembl)
#Write results to file
write.csv(searchResults,'search.csv',row.names=FALSE)