Last active
April 4, 2022 16:07
-
-
Save seandavi/f634cd3d68b59dc7d819d3de9e6f3474 to your computer and use it in GitHub Desktop.
GEOquery simple example for four cancer/normal samplesets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## ----message=FALSE,warning=FALSE---------------------------------------------- | |
pkgs = c( | |
"ggplot2", | |
"GEOquery", | |
"SummarizedExperiment" | |
) | |
ins = installed.packages(repos = BiocManager::repositories()) | |
for(pkg in pkgs) { | |
if(!(pkg %in% rownames(ins))) | |
BiocManager::install(pkg) | |
} | |
## ----------------------------------------------------------------------------- | |
## GEOquery | |
## ----------------------------------------------------------------------------- | |
library(GEOquery) | |
options("download.file.method.GEOquery"="curl") | |
gse = getGEO("GSE103512")[[1]] | |
## ----------------------------------------------------------------------------- | |
library(SummarizedExperiment) | |
se = as(gse, "SummarizedExperiment") | |
## ----geoquery20,echo=TRUE,cache=TRUE------------------------------------------ | |
with(colData(se),table(`cancer.type.ch1`,`normal.ch1`)) | |
## ----sds,cache=TRUE,echo=TRUE------------------------------------------------- | |
sds = apply(assay(se, 'exprs'),1,sd) | |
dat = assay(se, 'exprs')[order(sds,decreasing = TRUE)[1:500],] | |
## ----mds,echo=TRUE,cache=TRUE------------------------------------------------- | |
mdsvals = cmdscale(dist(t(dat))) | |
mdsvals = as.data.frame(mdsvals) | |
mdsvals$Type=factor(colData(se)[,'cancer.type.ch1']) | |
mdsvals$Normal = factor(colData(se)[,'normal.ch1']) | |
## ----mdsplot,echo=TRUE,fig.align='center'------------------------------------- | |
library(ggplot2) | |
ggplot(mdsvals, aes(x=V1,y=V2,shape=Normal,color=Type)) + | |
geom_point( alpha=0.6) + theme(text=element_text(size = 18)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment