library(Biobase)
## Loading required package: BiocGenerics
## Loading required package: parallel
## 
## Attaching package: 'BiocGenerics'
## The following objects are masked from 'package:parallel':
## 
##     clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
##     clusterExport, clusterMap, parApply, parCapply, parLapply,
##     parLapplyLB, parRapply, parSapply, parSapplyLB
## The following objects are masked from 'package:stats':
## 
##     IQR, mad, sd, var, xtabs
## The following objects are masked from 'package:base':
## 
##     anyDuplicated, append, as.data.frame, basename, cbind, colnames,
##     dirname, do.call, duplicated, eval, evalq, Filter, Find, get, grep,
##     grepl, intersect, is.unsorted, lapply, Map, mapply, match, mget,
##     order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank,
##     rbind, Reduce, rownames, sapply, setdiff, sort, table, tapply,
##     union, unique, unsplit, which, which.max, which.min
## Welcome to Bioconductor
## 
##     Vignettes contain introductory material; view with
##     'browseVignettes()'. To cite Bioconductor, see
##     'citation("Biobase")', and for packages 'citation("pkgname")'.
library(GEOquery)
## Setting options('download.file.method.GEOquery'='auto')
## Setting options('GEOquery.inmemory.gpl'=FALSE)
library(sva) # ComBat
## Loading required package: mgcv
## Loading required package: nlme
## This is mgcv 1.8-31. For overview type 'help("mgcv-package")'.
## Loading required package: genefilter
## Loading required package: BiocParallel
library(oligo)
## Loading required package: oligoClasses
## Welcome to oligoClasses version 1.50.4
## Loading required package: Biostrings
## Loading required package: S4Vectors
## Loading required package: stats4
## 
## Attaching package: 'S4Vectors'
## The following object is masked from 'package:base':
## 
##     expand.grid
## Loading required package: IRanges
## 
## Attaching package: 'IRanges'
## The following object is masked from 'package:nlme':
## 
##     collapse
## Loading required package: XVector
## 
## Attaching package: 'Biostrings'
## The following object is masked from 'package:base':
## 
##     strsplit
## No methods found in package 'RSQLite' for request: 'dbListFields' when loading 'oligo'
## ================================================================================
## Welcome to oligo version 1.52.1
## ================================================================================
library(googlesheets4)
library(stringr)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following object is masked from 'package:oligo':
## 
##     summarize
## The following objects are masked from 'package:Biostrings':
## 
##     collapse, intersect, setdiff, setequal, union
## The following object is masked from 'package:XVector':
## 
##     slice
## The following objects are masked from 'package:IRanges':
## 
##     collapse, desc, intersect, setdiff, slice, union
## The following objects are masked from 'package:S4Vectors':
## 
##     first, intersect, rename, setdiff, setequal, union
## The following object is masked from 'package:nlme':
## 
##     collapse
## The following object is masked from 'package:Biobase':
## 
##     combine
## The following objects are masked from 'package:BiocGenerics':
## 
##     combine, intersect, setdiff, union
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

Get the GEO dataset mostly for the phenoData annotation

gset <- getGEO("GSE47856", GSEMatrix =TRUE, getGPL=FALSE)
## Found 1 file(s)
## GSE47856_series_matrix.txt.gz
## Parsed with column specification:
## cols(
##   .default = col_double()
## )
## See spec(...) for full column specifications.
adf <- Biobase::phenoData(gset[[1]])
sampleNames(adf)
##   [1] "GSM1160723" "GSM1160724" "GSM1160725" "GSM1160726" "GSM1160727"
##   [6] "GSM1160728" "GSM1160729" "GSM1160730" "GSM1160731" "GSM1160732"
##  [11] "GSM1160733" "GSM1160734" "GSM1160735" "GSM1160736" "GSM1160737"
##  [16] "GSM1160738" "GSM1160739" "GSM1160740" "GSM1160741" "GSM1160742"
##  [21] "GSM1160743" "GSM1160744" "GSM1160745" "GSM1160746" "GSM1160747"
##  [26] "GSM1160748" "GSM1160749" "GSM1160750" "GSM1160751" "GSM1160752"
##  [31] "GSM1160753" "GSM1160754" "GSM1160755" "GSM1160756" "GSM1160757"
##  [36] "GSM1160758" "GSM1160759" "GSM1160760" "GSM1160761" "GSM1160762"
##  [41] "GSM1160763" "GSM1160764" "GSM1160765" "GSM1160766" "GSM1160767"
##  [46] "GSM1160768" "GSM1160769" "GSM1160770" "GSM1160771" "GSM1160772"
##  [51] "GSM1160773" "GSM1160774" "GSM1160775" "GSM1160776" "GSM1160777"
##  [56] "GSM1160778" "GSM1160779" "GSM1160780" "GSM1160781" "GSM1160782"
##  [61] "GSM1160783" "GSM1160784" "GSM1160785" "GSM1160786" "GSM1160787"
##  [66] "GSM1160788" "GSM1160789" "GSM1160790" "GSM1160791" "GSM1160792"
##  [71] "GSM1160793" "GSM1160794" "GSM1160795" "GSM1160796" "GSM1160797"
##  [76] "GSM1160798" "GSM1160799" "GSM1160800" "GSM1160801" "GSM1160802"
##  [81] "GSM1160803" "GSM1160804" "GSM1160805" "GSM1160806" "GSM1160807"
##  [86] "GSM1160808" "GSM1160809" "GSM1160810" "GSM1160811" "GSM1160812"
##  [91] "GSM1160813" "GSM1160814" "GSM1160815" "GSM1160816" "GSM1160817"
##  [96] "GSM1160818" "GSM1160819" "GSM1160820" "GSM1160821" "GSM1160822"
## [101] "GSM1160823" "GSM1160824" "GSM1160825" "GSM1160826" "GSM1160827"
## [106] "GSM1160828" "GSM1160829" "GSM1160830" "GSM1160831" "GSM1160832"
## [111] "GSM1160833" "GSM1160834" "GSM1160835" "GSM1160836" "GSM1160837"
## [116] "GSM1160838" "GSM1160839" "GSM1160840" "GSM1160841" "GSM1160842"
## [121] "GSM1160843" "GSM1160844" "GSM1160845" "GSM1160846" "GSM1160847"
## [126] "GSM1160848" "GSM1160849" "GSM1160850" "GSM1160851" "GSM1160852"
## [131] "GSM1160853" "GSM1160854" "GSM1160855" "GSM1160856" "GSM1160857"
## [136] "GSM1160858" "GSM1160859" "GSM1160860" "GSM1160861" "GSM1160862"
## [141] "GSM1160863" "GSM1160864" "GSM1160865" "GSM1160866" "GSM1160867"
## [146] "GSM1160868" "GSM1160869" "GSM1160870" "GSM1160871" "GSM1160872"
## [151] "GSM1160873" "GSM1160874" "GSM1160875" "GSM1160876" "GSM1160877"
## [156] "GSM1160878" "GSM1160879" "GSM1160880" "GSM1160881" "GSM1160882"
## [161] "GSM1160883" "GSM1160884" "GSM1160885" "GSM1160886" "GSM1160887"
## [166] "GSM1160888" "GSM1160889" "GSM1160890" "GSM1160891" "GSM1160892"
## [171] "GSM1160893"

Read RAW cel files from the GEO data supplementary rar archive https://www.ncbi.nlm.nih.gov/geo/download/?acc=GSE47856&format=file In my case extracted to ~/Downloads/cel Ensure that we read them in the same order as the phenoData object

celfiles <- sapply(sampleNames(adf), function(f) {
  pat <- paste0(f, ".*.CEL.gz$")
  dir("~/Downloads/cel", pattern = pat, full.names = TRUE)
})
raw_data <- oligo::read.celfiles(celfiles,
                                 phenoData = adf, 
                                 experimentData = experimentData(gset[[1]]))
## Loading required package: pd.hugene.1.0.st.v1
## Loading required package: RSQLite
## Loading required package: DBI
## Platform design info loaded.
## Reading in : /home/bs/Downloads/cel/GSM1160723_SMhu001.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160724_SMhu001b.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160725_SMhu002.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160726_SMhu002b.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160727_SMhu003.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160728_SMhu004.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160729_SMhu006.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160730_SMhu007.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160731_SMhu008.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160732_SMhu009.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160733_SMhu010.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160734_SMhu011.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160735_SMhu012.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160736_SMhu013.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160737_SMhu014.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160738_SMhu015.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160739_SMhu016.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160740_SMhu017.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160741_SMhu018.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160742_SMhu019.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160743_SMhu020.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160744_SMhu021.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160745_SMhu022.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160746_SMhu023.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160747_SMhu024.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160748_SMhu025.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160749_SMhu026.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160750_SMhu027.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160751_SMhu028.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160752_SMhu029.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160753_SMhu030.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160754_SMhu031.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160755_SMhu032.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160756_SMhu033.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160757_SMhu034.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160758_SMhu035.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160759_SMhu036.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160760_SMhu037.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160761_SMhu038.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160762_SMhu039.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160763_SMhu040.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160764_SMhu041.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160765_SMhu042.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160766_SMhu049.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160767_SMhu050.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160768_SMhu051.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160769_SMhu052.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160770_SMhu053.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160771_SMhu054.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160772_SMhu061.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160773_SMhu062.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160774_SMhu063.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160775_SMhu064.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160776_SMhu065.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160777_SMhu066.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160778_SMhu067.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160779_SMhu068.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160780_SMhu069.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160781_SMhu070.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160782_SMhu071.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160783_SMhu072.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160784_SMhu079.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160785_SMhu080.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160786_SMhu081.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160787_SMhu082.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160788_SMhu083.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160789_SMhu084.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160790_SMhu085.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160791_SMhu085b.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160792_SMhu086.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160793_SMhu086b.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160794_SMhu087.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160795_SMhu088.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160796_SMhu089.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160797_SMhu090.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160798_SMhu091.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160799_SMhu092.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160800_SMhu093.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160801_SMhu094.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160802_SMhu095.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160803_SMhu096.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160804_SMhu097.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160805_SMhu098.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160806_SMhu099.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160807_SMhu100.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160808_SMhu101.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160809_SMhu102.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160810_SMhu103.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160811_SMhu104.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160812_SMhu105.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160813_SMhu106.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160814_SMhu107.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160815_SMhu108.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160816_SMhu109.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160817_SMhu110.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160818_SMhu111.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160819_SMhu112.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160820_SMhu113.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160821_SMhu114.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160822_SMhu115.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160823_SMhu116.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160824_SMhu117.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160825_SMhu118.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160826_SMhu119.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160827_SMhu120.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160828_SMhu121.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160829_SMhu122.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160830_SMhu123.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160831_SMhu124.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160832_SMhu125.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160833_SMhu126.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160834_SMhu127.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160835_SMhu128.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160836_SMhu129.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160837_SMhu130.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160838_SMhu131.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160839_SMhu132.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160840_SMhu133.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160841_SMhu134.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160842_SMhu135.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160843_SMhu136.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160844_SMhu137.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160845_SMhu138.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160846_SMhu139.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160847_SMhu140.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160848_SMhu141.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160849_SMhu142.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160850_SMhu143.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160851_SMhu144.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160852_SMhu145.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160853_SMhu146.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160854_SMhu147.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160855_SMhu148.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160856_SMhu149.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160857_SMhu150.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160858_SMhu151.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160859_SMhu152.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160860_SMhu153.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160861_SMhu154.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160862_SMhu155.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160863_SMhu156.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160864_SMhu157.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160865_SMhu158.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160866_SMhu159.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160867_SMhu160.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160868_SMhu161.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160869_SMhu162.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160870_SMhu163.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160871_SMhu164.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160872_SMhu165.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160873_SMhu166.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160874_SMhu167.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160875_SMhu168.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160876_SMhu169.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160877_SMhu170.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160878_SMhu171.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160879_SMhu172.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160880_SMhu173.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160881_SMhu174.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160882_SMhu175.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160883_SMhu176.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160884_SMhu177.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160885_SMhu178.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160886_SMhu179.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160887_SMhu180.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160888_SMhu181.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160889_SMhu182.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160890_SMhu183.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160891_SMhu184.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160892_SMhu185.CEL.gz
## Reading in : /home/bs/Downloads/cel/GSM1160893_SMhu186.CEL.gz
## Warning in oligo::read.celfiles(celfiles, phenoData = adf, experimentData =
## experimentData(gset[[1]])): 'channel' automatically added to varMetadata in
## phenoData.

Get the raw expression and RMA on transcript clusters

rma_expr <- oligo::rma(raw_data, target = "core")
## Background correcting
## Normalizing
## Calculating Expression
rma_expr_assay <- assayData(rma_expr)$exprs

Use ComBat for batch effect removal

batch_data <- phenoData(rma_expr)@data$`batch:ch1`
cb_expr <- sva::ComBat(rma_expr_assay, batch_data)
## Found5batches
## Adjusting for0covariate(s) or covariate level(s)
## Standardizing Data across genes
## Fitting L/S model and finding priors
## Finding parametric adjustments
## Adjusting the Data

Get supplementary table 1 from the paper (which I copied on this Google Sheet)

supp_data <- read_sheet("https://docs.google.com/spreadsheets/d/142__1O35zvlttejvz62XQX33uLRJhqIDvb604smVSRo")
## Using an auto-discovered, cached token.
## To suppress this message, modify your code or options to clearly consent to the use of a cached token.
## See gargle's "Non-interactive auth" vignette for more details:
## https://gargle.r-lib.org/articles/non-interactive-auth.html
## The googlesheets4 package is using a cached token for b.schiffthaler@gmail.com.
## Reading from "se_14571_supp_tables"
## Range "Suppl. Tab1"

Match the ‘cell line’ phenotype from the phenoData to the sample info of the supplementary table and extract the cell classification. Also remove all white space and convert everything to lower case for easier matching. Some cell lines also have a/b attached, so I’m dropping that to match them up. Mayb not be correct to do that here and treat all a/b the same (?)

cell_line <- str_replace(
  str_replace(
  str_remove(
    str_to_lower(adf[["cell line:ch1"]]),
    " +"),
  "^tay$", "taya"),
  "dov13[ab]", "dov13"
)

sample_info <- str_remove(str_to_lower(supp_data$Sample), " +")
classification <- supp_data$Classification[match(cell_line, sample_info)]

Get the treament from the phenoData object

treatment <- adf[["treatment:ch1"]]

We’ll need the geometric mean later (R has no built-in)

gm_mean = function(x, na.rm=TRUE){
  exp(sum(log(x[x > 0]), na.rm=na.rm) / length(x))
}

Set up a tibble (==data frame) with all that info for your probe

tibble(Expression = cb_expr["8143663", ], 
       Line = cell_line, 
       Treatment = treatment, 
       Classification = classification) %>%
  # Summarise replicated data with the geometric mean
  group_by(Line, Treatment, Classification) %>%
  summarise(Emean = gm_mean(Expression)) %>% 
  # Make sure data is in order
  arrange(Line, Treatment, Classification)%>%
  # Calculate the difference between the cell types
  group_by(Line, Classification) %>%
  summarise(EmeanDiff = diff(Emean)) -> xdata
## `summarise()` regrouping output by 'Line', 'Treatment' (override with `.groups` argument)
## `summarise()` regrouping output by 'Line' (override with `.groups` argument)

Test the difference

xdata <- split(xdata$EmeanDiff, xdata$Classification)
wilcox.test(x = xdata$`Epithelial-like`, y = xdata$`Mesenchymal-like`,
            exact = TRUE)
## 
##  Wilcoxon rank sum exact test
## 
## data:  xdata$`Epithelial-like` and xdata$`Mesenchymal-like`
## W = 121, p-value = 0.004059
## alternative hypothesis: true location shift is not equal to 0

Session info

sessionInfo()
## R version 4.0.2 (2020-06-22)
## Platform: x86_64-redhat-linux-gnu (64-bit)
## Running under: Fedora 32 (Thirty Two)
## 
## Matrix products: default
## BLAS/LAPACK: /usr/lib64/libopenblas-r0.3.10.so
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats4    parallel  stats     graphics  grDevices utils     datasets 
## [8] methods   base     
## 
## other attached packages:
##  [1] pd.hugene.1.0.st.v1_3.14.1 DBI_1.1.0                 
##  [3] RSQLite_2.2.0              dplyr_1.0.2               
##  [5] stringr_1.4.0              googlesheets4_0.2.0       
##  [7] oligo_1.52.1               Biostrings_2.56.0         
##  [9] XVector_0.28.0             IRanges_2.22.2            
## [11] S4Vectors_0.26.1           oligoClasses_1.50.4       
## [13] sva_3.36.0                 BiocParallel_1.22.0       
## [15] genefilter_1.70.0          mgcv_1.8-31               
## [17] nlme_3.1-148               GEOquery_2.56.0           
## [19] Biobase_2.48.0             BiocGenerics_0.34.0       
## 
## loaded via a namespace (and not attached):
##  [1] bitops_1.0-6                matrixStats_0.56.0         
##  [3] fs_1.5.0                    bit64_4.0.5                
##  [5] httr_1.4.2                  GenomeInfoDb_1.24.2        
##  [7] tools_4.0.2                 R6_2.4.1                   
##  [9] affyio_1.58.0               withr_2.2.0                
## [11] tidyselect_1.1.0            bit_4.0.4                  
## [13] curl_4.3                    compiler_4.0.2             
## [15] preprocessCore_1.50.0       xml2_1.3.2                 
## [17] DelayedArray_0.14.1         readr_1.3.1                
## [19] askpass_1.1                 digest_0.6.25              
## [21] rmarkdown_2.4               pkgconfig_2.0.3            
## [23] htmltools_0.5.0             limma_3.44.3               
## [25] highr_0.8                   rlang_0.4.7                
## [27] generics_0.0.2              jsonlite_1.7.1             
## [29] RCurl_1.98-1.2              magrittr_1.5               
## [31] GenomeInfoDbData_1.2.3      Matrix_1.2-18              
## [33] Rcpp_1.0.5                  lifecycle_0.2.0            
## [35] stringi_1.5.3               yaml_2.2.1                 
## [37] edgeR_3.30.3                SummarizedExperiment_1.18.2
## [39] zlibbioc_1.34.0             grid_4.0.2                 
## [41] affxparser_1.60.0           blob_1.2.1                 
## [43] crayon_1.3.4                lattice_0.20-41            
## [45] splines_4.0.2               annotate_1.66.0            
## [47] hms_0.5.3                   locfit_1.5-9.4             
## [49] knitr_1.30                  pillar_1.4.6               
## [51] GenomicRanges_1.40.0        codetools_0.2-16           
## [53] XML_3.99-0.5                glue_1.4.2                 
## [55] evaluate_0.14               BiocManager_1.30.10        
## [57] vctrs_0.3.4                 foreach_1.5.0              
## [59] cellranger_1.1.0            openssl_1.4.3              
## [61] purrr_0.3.4                 tidyr_1.1.2                
## [63] xfun_0.18                   xtable_1.8-4               
## [65] ff_4.0.4                    survival_3.1-12            
## [67] googledrive_1.0.1           gargle_0.5.0               
## [69] tibble_3.0.3                iterators_1.0.12           
## [71] AnnotationDbi_1.50.3        memoise_1.1.0              
## [73] ellipsis_0.3.1