# Install GEOquery if you haven't already
> if (!requireNamespace("GEOquery", quietly = TRUE)) {
+ if (!requireNamespace("BiocManager", quietly = TRUE)) {
+ install.packages("BiocManager")
+ }
+ BiocManager::install("GEOquery")
+ }
>
> library(GEOquery)
>
> search_GEO_series <- function(keywords, organism, source, sample_type, molecule, library_strategy) {
+ query <- paste(keywords, collapse = " OR ")
+ term <- paste0("(", query, ") AND ", organism, " AND ", source, " AND ", sample_type, " AND ", molecule, " AND ", library_strategy, " AND GSE[ETYP]")
+
+ # Use the getGEO function to fetch the search results
+ search_results <- getGEO(term, GSEMatrix = FALSE)
+
+ # Extract GSE IDs from the search results
+ gse_ids <- sapply(search_results, function(result) {
+ header <- Meta(result)
+ return(header$geo_accession)
+ })
+
+ return(unique(gse_ids))
+ }
>
> keywords <- c("RNA-Seq", "transcriptome sequencing")
> organism <- "Homo sapiens"
> source <- "T cells AND CD4 AND CD8"
> sample_type <- "SRA"
> molecule <- "RNA"
> library_strategy <- "RNA-seq"
>
> gse_ids <- search_GEO_series(keywords, organism, source, sample_type, molecule, library_strategy)
Error in getGEOfile(GEO, destdir = destdir, AnnotGPL = AnnotGPL) :
object 'destfile' not found
>
how many times ever i run this code iam not able to get a result. iam completely new to coding and R. SO i would be glad if someone could help.
Another alternative is to use the
GEOmetadb
package (vignette here), which will allow you to make queries to identify GEO datasets that fulfill a set of criteria.