R libraries and Bioconductor¶
Packages and Libraries¶
R is at heart a collection of ‘packages’. There is a ‘base’ system that contains the truly basic commands, such as the assignment operator -> or the command to create a vector. In addition to that, there are ‘standard R’ packages that are included when you install the R kernel (in the Jupyter notebook), or ‘R’ as a program to run either at the command line or with Rstudio. (I’ve shown some examples of these different ways to run R in class).
Libraries¶
Many packages, even those included in [standard R] (https://www.r-project.org/), will need to be ‘loaded’ to be used. In other words, they exist on your computer (or in your container), but the R kernel doesn’t know about them. This is because if it did, R would be using computer memory (RAM) to remember all their functions and variables. If all the available packages were loaded, you might not have any RAM left!
A consequence of this is that you often have to tell R explicitly that you want to use a particular package. You do that using library. Let’s read in the titanic data set to have something to play with.
[1]:
titanic <- read.csv("titanic.csv")
[2]:
head(titanic)
| X | Name | PClass | Age | Sex | Survived | SexCode |
|---|---|---|---|---|---|---|
| <int> | <fct> | <fct> | <dbl> | <fct> | <int> | <int> |
| 1 | Allen, Miss Elisabeth Walton | 1st | 29.00 | female | 1 | 1 |
| 2 | Allison, Miss Helen Loraine | 1st | 2.00 | female | 0 | 1 |
| 3 | Allison, Mr Hudson Joshua Creighton | 1st | 30.00 | male | 0 | 0 |
| 4 | Allison, Mrs Hudson JC (Bessie Waldo Daniels) | 1st | 25.00 | female | 0 | 1 |
| 5 | Allison, Master Hudson Trevor | 1st | 0.92 | male | 1 | 0 |
| 6 | Anderson, Mr Harry | 1st | 47.00 | male | 1 | 0 |
There is a cool R function that will allow us to look at some random rows from a data frame. It’s called sample_n. Let’s try it:
[3]:
sample_n(titanic, 10)
Error in sample_n(titanic, 10): could not find function "sample_n"
Traceback:
Oops. It turns out sample_n is in the dplyr package. It’s installed in your container - but R doesn’t know that! Let’s tell R we want to use it:
[4]:
library(dplyr)
Attaching package: ‘dplyr’
The following objects are masked from ‘package:stats’:
filter, lag
The following objects are masked from ‘package:base’:
intersect, setdiff, setequal, union
[5]:
sample_n(titanic, 10)
| X | Name | PClass | Age | Sex | Survived | SexCode |
|---|---|---|---|---|---|---|
| <int> | <fct> | <fct> | <dbl> | <fct> | <int> | <int> |
| 304 | Geiger, Miss Emily | 1st | NA | female | 1 | 1 |
| 675 | Birkeland, Mr Hans | 3rd | 21 | male | 0 | 0 |
| 555 | Sincock, Miss Maude | 2nd | 20 | female | 1 | 1 |
| 52 | Case, Mr Howard Brown | 1st | 49 | male | 0 | 0 |
| 125 | Greenfield, Mrs Leo David (Blanche Strouse) | 1st | 45 | female | 1 | 1 |
| 427 | Harbeck, Mr William H | 2nd | 44 | male | 0 | 0 |
| 195 | Ostby, Miss Helen Raghnild | 1st | 22 | female | 1 | 1 |
| 1183 | Salkjelsvik, Miss Anna | 3rd | NA | female | 1 | 1 |
| 953 | Leeni, Mr Fahim | 3rd | NA | male | 1 | 0 |
| 935 | Kink, Miss Maria | 3rd | 22 | female | 0 | 1 |
Installed and installing packages¶
Now, dplyr is actually not part of standard R. It’s installed separately. There are a multitude of R packages out there. Anyone can write one (yes, even you!!!). They are shared with the public using the [CRAN archive.] (https://cran.r-project.org/) In order to be listed in CRAN, packages need to meet specific criteria for documentation purposes, testing, etc.
You can check to see what packages are installed using installed.packages()
[6]:
installed.packages()
| Package | LibPath | Version | Priority | Depends | Imports | LinkingTo | Suggests | Enhances | License | License_is_FOSS | License_restricts_use | OS_type | MD5sum | NeedsCompilation | Built | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| countrycode | countrycode | /home/jovyan/R/x86_64-pc-linux-gnu-library/3.6 | 1.1.0 | NA | R (>= 2.10) | NA | NA | testthat (>= 0.5) | NA | GPL-3 | NA | NA | NA | NA | no | 3.6.0 |
| acepack | acepack | /usr/local/lib/R/site-library | 1.4.1 | NA | NA | NA | NA | testthat | NA | MIT + file LICENSE | NA | NA | NA | NA | yes | 3.6.0 |
| ade4 | ade4 | /usr/local/lib/R/site-library | 1.7-13 | NA | R (>= 2.10) | graphics, grDevices, methods, stats, utils, MASS | NA | ade4TkGUI, adegraphics, adephylo, ape, CircStats, deldir, lattice, pixmap, sp, spdep, splancs, waveslim | NA | GPL (>= 2) | NA | NA | NA | NA | yes | 3.6.0 |
| airway | airway | /usr/local/lib/R/site-library | 1.4.0 | NA | R (>= 2.10), SummarizedExperiment | NA | NA | knitr, GEOquery | NA | LGPL | NA | NA | NA | NA | no | 3.6.0 |
| annotate | annotate | /usr/local/lib/R/site-library | 1.62.0 | NA | R (>= 2.10), AnnotationDbi (>= 1.27.5), XML | Biobase, DBI, xtable, graphics, utils, stats, methods, BiocGenerics (>= 0.13.8), RCurl | NA | hgu95av2.db, genefilter, Biostrings (>= 2.25.10), IRanges, rae230a.db, rae230aprobe, tkWidgets, GO.db, org.Hs.eg.db, org.Mm.eg.db, hom.Hs.inp.db, humanCHRLOC, Rgraphviz, RUnit, | NA | Artistic-2.0 | NA | NA | NA | NA | no | 3.6.0 |
| AnnotationDbi | AnnotationDbi | /usr/local/lib/R/site-library | 1.46.0 | NA | R (>= 2.7.0), methods, utils, stats4, BiocGenerics (>= 0.29.2), Biobase (>= 1.17.0), IRanges | DBI, RSQLite, S4Vectors (>= 0.9.25) | NA | hgu95av2.db, GO.db, org.Sc.sgd.db, org.At.tair.db, KEGG.db, RUnit, TxDb.Hsapiens.UCSC.hg19.knownGene, hom.Hs.inp.db, org.Hs.eg.db, reactome.db, AnnotationForge, graph, EnsDb.Hsapiens.v75, BiocStyle, knitr | NA | Artistic-2.0 | NA | NA | NA | NA | no | 3.6.0 |
| AnnotationFilter | AnnotationFilter | /usr/local/lib/R/site-library | 1.8.0 | NA | R (>= 3.4.0) | utils, methods, GenomicRanges, lazyeval | NA | BiocStyle, knitr, testthat, RSQLite, org.Hs.eg.db | NA | Artistic-2.0 | NA | NA | NA | NA | no | 3.6.0 |
| ape | ape | /usr/local/lib/R/site-library | 5.3 | NA | R (>= 3.2.0) | nlme, lattice, graphics, methods, stats, tools, utils, parallel, Rcpp (>= 0.12.0) | Rcpp | gee, expm, igraph | NA | GPL (>= 2) | NA | NA | NA | NA | yes | 3.6.0 |
| askpass | askpass | /usr/local/lib/R/site-library | 1.1 | NA | NA | sys (>= 2.1) | NA | testthat | NA | MIT + file LICENSE | NA | NA | NA | NA | yes | 3.6.0 |
| assertthat | assertthat | /usr/local/lib/R/site-library | 0.2.1 | NA | NA | tools | NA | testthat, covr | NA | GPL-3 | NA | NA | NA | NA | no | 3.6.0 |
| backports | backports | /usr/local/lib/R/site-library | 1.1.4 | NA | R (>= 3.0.0) | utils | NA | NA | NA | GPL-2 | NA | NA | NA | NA | yes | 3.6.0 |
| base64enc | base64enc | /usr/local/lib/R/site-library | 0.1-3 | NA | R (>= 2.9.0) | NA | NA | NA | png | GPL-2 | GPL-3 | NA | NA | NA | NA | yes | 3.6.0 |
| BH | BH | /usr/local/lib/R/site-library | 1.69.0-1 | NA | NA | NA | NA | NA | NA | BSL-1.0 | NA | NA | NA | NA | no | 3.6.0 |
| Biobase | Biobase | /usr/local/lib/R/site-library | 2.44.0 | NA | R (>= 2.10), BiocGenerics (>= 0.27.1), utils | methods | NA | tools, tkWidgets, ALL, RUnit, golubEsets | NA | Artistic-2.0 | NA | NA | NA | NA | yes | 3.6.0 |
| BiocGenerics | BiocGenerics | /usr/local/lib/R/site-library | 0.30.0 | NA | R (>= 3.6.0), methods, utils, graphics, stats, parallel | methods, utils, graphics, stats, parallel | NA | Biobase, S4Vectors, IRanges, GenomicRanges, Rsamtools, AnnotationDbi, oligoClasses, oligo, affyPLM, flowClust, affy, DESeq2, MSnbase, annotate, RUnit | NA | Artistic-2.0 | NA | NA | NA | NA | no | 3.6.0 |
| BiocManager | BiocManager | /usr/local/lib/R/site-library | 1.30.4 | NA | R (>= 3.5.0) | utils | NA | BiocStyle, BiocVersion, remotes, testthat, knitr, withr | NA | Artistic-2.0 | NA | NA | NA | NA | no | 3.6.0 |
| BiocParallel | BiocParallel | /usr/local/lib/R/site-library | 1.18.0 | NA | methods | stats, utils, futile.logger, parallel, snow | BH | BiocGenerics, tools, foreach, BatchJobs, BBmisc, doParallel, Rmpi, GenomicRanges, RNAseqData.HNRNPC.bam.chr14, TxDb.Hsapiens.UCSC.hg19.knownGene, VariantAnnotation, Rsamtools, GenomicAlignments, ShortRead, codetools, RUnit, BiocStyle, knitr, batchtools, data.table | NA | GPL-2 | GPL-3 | NA | NA | NA | NA | yes | 3.6.0 |
| BiocVersion | BiocVersion | /usr/local/lib/R/site-library | 3.9.0 | NA | R (>= 3.6.0), R (< 3.7.0) | NA | NA | NA | NA | Artistic-2.0 | NA | NA | NA | NA | no | 3.6.0 |
| biomaRt | biomaRt | /usr/local/lib/R/site-library | 2.40.0 | NA | methods | utils, XML, RCurl, AnnotationDbi, progress, stringr, httr | NA | annotate, BiocStyle, knitr, rmarkdown, testthat | NA | Artistic-2.0 | NA | NA | NA | NA | no | 3.6.0 |
| biomformat | biomformat | /usr/local/lib/R/site-library | 1.12.0 | NA | R (>= 3.2), methods | plyr (>= 1.8), jsonlite (>= 0.9.16), Matrix (>= 1.2), rhdf5 | NA | testthat (>= 0.10), knitr (>= 1.10), BiocStyle (>= 1.6), rmarkdown (>= 0.7) | NA | GPL-2 | NA | NA | NA | NA | no | 3.6.0 |
| Biostrings | Biostrings | /usr/local/lib/R/site-library | 2.52.0 | NA | R (>= 3.5.0), methods, BiocGenerics, S4Vectors (>= 0.21.13), IRanges, XVector (>= 0.23.2) | graphics, methods, stats, utils | S4Vectors, IRanges, XVector | BSgenome (>= 1.13.14), BSgenome.Celegans.UCSC.ce2 (>= 1.3.11), BSgenome.Dmelanogaster.UCSC.dm3 (>= 1.3.11), BSgenome.Hsapiens.UCSC.hg18, drosophila2probe, hgu95av2probe, hgu133aprobe, GenomicFeatures (>= 1.3.14), hgu95av2cdf, affy (>= 1.41.3), affydata (>= 1.11.5), RUnit | Rmpi | Artistic-2.0 | NA | NA | NA | NA | yes | 3.6.0 |
| biovizBase | biovizBase | /usr/local/lib/R/site-library | 1.32.0 | NA | R (>= 2.10), methods | grDevices, stats, scales, Hmisc, RColorBrewer, dichromat, BiocGenerics, S4Vectors (>= 0.9.25), IRanges (>= 1.99.28), GenomeInfoDb (>= 1.5.14), GenomicRanges (>= 1.23.21), SummarizedExperiment, Biostrings (>= 2.33.11), Rsamtools (>= 1.17.28), GenomicAlignments (>= 1.1.16), GenomicFeatures (>= 1.21.19), AnnotationDbi, VariantAnnotation (>= 1.11.4), ensembldb (>= 1.99.13), AnnotationFilter (>= 0.99.8), rlang | NA | BSgenome.Hsapiens.UCSC.hg19, TxDb.Hsapiens.UCSC.hg19.knownGene, BSgenome, rtracklayer, EnsDb.Hsapiens.v75, RUnit | NA | Artistic-2.0 | NA | NA | NA | NA | yes | 3.6.0 |
| bit | bit | /usr/local/lib/R/site-library | 1.1-14 | NA | R (>= 2.9.2) | NA | NA | NA | NA | GPL-2 | NA | NA | NA | NA | yes | 3.6.0 |
| bit64 | bit64 | /usr/local/lib/R/site-library | 0.9-7 | NA | R (>= 3.0.1), bit (>= 1.1-12), utils, methods, stats | NA | NA | NA | NA | GPL-2 | NA | NA | NA | NA | yes | 3.6.0 |
| bitops | bitops | /usr/local/lib/R/site-library | 1.0-6 | NA | NA | NA | NA | NA | NA | GPL (>= 2) | NA | NA | NA | NA | yes | 3.6.0 |
| blob | blob | /usr/local/lib/R/site-library | 1.1.1 | NA | NA | methods, prettyunits | NA | covr, pillar (>= 1.2.1), testthat | NA | GPL-3 | NA | NA | NA | NA | no | 3.6.0 |
| broom | broom | /usr/local/lib/R/site-library | 0.5.2 | NA | R (>= 3.1) | backports, dplyr, generics (>= 0.0.2), methods, nlme, purrr, reshape2, stringr, tibble, tidyr | NA | AER, akima, AUC, bbmle, betareg, biglm, binGroup, boot, brms, btergm, car, caret, coda, covr, e1071, emmeans, ergm, gam (>= 1.15), gamlss, gamlss.data, gamlss.dist, geepack, ggplot2, glmnet, gmm, Hmisc, irlba, joineRML, Kendall, knitr, ks, Lahman, lavaan, lfe, lme4, lmodel2, lmtest, lsmeans, maps, maptools, MASS, Matrix, mclust, mgcv, muhaz, multcomp, network, nnet, orcutt (>= 2.2), ordinal, plm, plyr, poLCA, psych, quantreg, rgeos, rmarkdown, robust, rsample, rstan, rstanarm, sp, speedglm, statnet.common, survey, survival, testthat, tseries, xergm, zoo | NA | MIT + file LICENSE | NA | NA | NA | NA | no | 3.6.0 |
| BSgenome | BSgenome | /usr/local/lib/R/site-library | 1.52.0 | NA | R (>= 2.8.0), methods, BiocGenerics (>= 0.13.8), S4Vectors (>= 0.17.28), IRanges (>= 2.13.16), GenomeInfoDb (>= 1.15.2), GenomicRanges (>= 1.31.10), Biostrings (>= 2.47.6), rtracklayer (>= 1.39.7) | methods, utils, stats, BiocGenerics, S4Vectors, IRanges, XVector, GenomeInfoDb, GenomicRanges, Biostrings, Rsamtools, rtracklayer | NA | BiocManager, Biobase, BSgenome.Celegans.UCSC.ce2, BSgenome.Hsapiens.UCSC.hg38, BSgenome.Hsapiens.UCSC.hg38.masked, BSgenome.Mmusculus.UCSC.mm10, BSgenome.Rnorvegicus.UCSC.rn5, BSgenome.Scerevisiae.UCSC.sacCer1, TxDb.Hsapiens.UCSC.hg38.knownGene, TxDb.Mmusculus.UCSC.mm10.knownGene, SNPlocs.Hsapiens.dbSNP144.GRCh38, XtraSNPlocs.Hsapiens.dbSNP144.GRCh38, hgu95av2probe, RUnit | NA | Artistic-2.0 | NA | NA | NA | NA | no | 3.6.0 |
| callr | callr | /usr/local/lib/R/site-library | 3.2.0 | NA | NA | processx (>= 3.3.0), R6, utils | NA | cliapp, covr, crayon, pingr, ps, testthat, withr | NA | MIT + file LICENSE | NA | NA | NA | NA | no | 3.6.0 |
| caret | caret | /usr/local/lib/R/site-library | 6.0-84 | NA | R (>= 3.2.0), lattice (>= 0.20), ggplot2 | foreach, methods, plyr, ModelMetrics (>= 1.1.0), nlme, reshape2, stats, stats4, utils, grDevices, recipes (>= 0.1.4), withr (>= 2.0.0) | NA | BradleyTerry2, e1071, earth (>= 2.2-3), fastICA, gam (>= 1.15), ipred, kernlab, knitr, klaR, MASS, ellipse, mda, mgcv, mlbench, MLmetrics, nnet, party (>= 0.9-99992), pls, pROC, proxy, randomForest, RANN, spls, subselect, pamr, superpc, Cubist, testthat (>= 0.9.1), rpart, dplyr | NA | GPL (>= 2) | NA | NA | NA | NA | yes | 3.6.0 |
| ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ |
| zoo | zoo | /usr/local/lib/R/site-library | 1.8-6 | NA | R (>= 3.1.0), stats | utils, graphics, grDevices, lattice (>= 0.20-27) | NA | coda, chron, DAAG, fts, ggplot2, mondate, scales, strucchange, timeDate, timeSeries, tis, tseries, xts | NA | GPL-2 | GPL-3 | NA | NA | NA | NA | yes | 3.6.0 |
| base | base | /usr/lib/R/library | 3.6.0 | base | NA | NA | NA | methods | NA | Part of R 3.6.0 | NA | NA | NA | NA | NA | 3.6.0 |
| boot | boot | /usr/lib/R/library | 1.3-20 | recommended | R (>= 3.0.0), graphics, stats | NA | NA | MASS, survival | NA | Unlimited | NA | NA | NA | NA | no | 3.5.1 |
| class | class | /usr/lib/R/library | 7.3-15 | recommended | R (>= 3.0.0), stats, utils | MASS | NA | NA | NA | GPL-2 | GPL-3 | NA | NA | NA | NA | yes | 3.6.0 |
| cluster | cluster | /usr/lib/R/library | 2.0.8 | recommended | R (>= 3.3.0) | graphics, grDevices, stats, utils | NA | MASS, Matrix | NA | GPL (>= 2) | NA | NA | NA | NA | yes | 3.6.0 |
| codetools | codetools | /usr/lib/R/library | 0.2-16 | recommended | R (>= 2.1) | NA | NA | NA | NA | GPL | NA | NA | NA | NA | no | 3.5.3 |
| compiler | compiler | /usr/lib/R/library | 3.6.0 | base | NA | NA | NA | NA | NA | Part of R 3.6.0 | NA | NA | NA | NA | NA | 3.6.0 |
| datasets | datasets | /usr/lib/R/library | 3.6.0 | base | NA | NA | NA | NA | NA | Part of R 3.6.0 | NA | NA | NA | NA | NA | 3.6.0 |
| foreign | foreign | /usr/lib/R/library | 0.8-71 | recommended | R (>= 3.0.0) | methods, utils, stats | NA | NA | NA | GPL (>= 2) | NA | NA | NA | NA | yes | 3.6.0 |
| graphics | graphics | /usr/lib/R/library | 3.6.0 | base | NA | grDevices | NA | NA | NA | Part of R 3.6.0 | NA | NA | NA | NA | yes | 3.6.0 |
| grDevices | grDevices | /usr/lib/R/library | 3.6.0 | base | NA | NA | NA | KernSmooth | NA | Part of R 3.6.0 | NA | NA | NA | NA | yes | 3.6.0 |
| grid | grid | /usr/lib/R/library | 3.6.0 | base | NA | grDevices, utils | NA | lattice | NA | Part of R 3.6.0 | NA | NA | NA | NA | yes | 3.6.0 |
| KernSmooth | KernSmooth | /usr/lib/R/library | 2.23-15 | recommended | R (>= 2.5.0), stats | NA | NA | MASS | NA | Unlimited | NA | NA | NA | NA | yes | 3.6.0 |
| lattice | lattice | /usr/lib/R/library | 0.20-38 | recommended | R (>= 3.0.0) | grid, grDevices, graphics, stats, utils | NA | KernSmooth, MASS, latticeExtra | chron | GPL (>= 2) | NA | NA | NA | NA | yes | 3.6.0 |
| MASS | MASS | /usr/lib/R/library | 7.3-51.3 | recommended | R (>= 3.1.0), grDevices, graphics, stats, utils | methods | NA | lattice, nlme, nnet, survival | NA | GPL-2 | GPL-3 | NA | NA | NA | NA | yes | 3.6.0 |
| Matrix | Matrix | /usr/lib/R/library | 1.2-17 | recommended | R (>= 3.2.0) | methods, graphics, grid, stats, utils, lattice | NA | expm, MASS | MatrixModels, graph, SparseM, sfsmisc | GPL (>= 2) | file LICENCE | NA | NA | NA | NA | yes | 3.6.0 |
| methods | methods | /usr/lib/R/library | 3.6.0 | base | NA | utils, stats | NA | codetools | NA | Part of R 3.6.0 | NA | NA | NA | NA | yes | 3.6.0 |
| mgcv | mgcv | /usr/lib/R/library | 1.8-28 | recommended | R (>= 2.14.0), nlme (>= 3.1-64) | methods, stats, graphics, Matrix, splines, utils | NA | parallel, survival, MASS | NA | GPL (>= 2) | NA | NA | NA | NA | yes | 3.6.0 |
| nlme | nlme | /usr/lib/R/library | 3.1-139 | recommended | R (>= 3.4.0) | graphics, stats, utils, lattice | NA | Hmisc, MASS | NA | GPL (>= 2) | file LICENCE | NA | NA | NA | NA | yes | 3.6.0 |
| nnet | nnet | /usr/lib/R/library | 7.3-12 | recommended | R (>= 2.14.0), stats, utils | NA | NA | MASS | NA | GPL-2 | GPL-3 | NA | NA | NA | NA | yes | 3.6.0 |
| parallel | parallel | /usr/lib/R/library | 3.6.0 | base | NA | tools, compiler | NA | methods | snow, nws, Rmpi | Part of R 3.6.0 | NA | NA | NA | NA | yes | 3.6.0 |
| rpart | rpart | /usr/lib/R/library | 4.1-15 | recommended | R (>= 2.15.0), graphics, stats, grDevices | NA | NA | survival | NA | GPL-2 | GPL-3 | NA | NA | NA | NA | yes | 3.6.0 |
| spatial | spatial | /usr/lib/R/library | 7.3-11 | recommended | R (>= 3.0.0), graphics, stats, utils | NA | NA | MASS | NA | GPL-2 | GPL-3 | NA | NA | NA | NA | yes | 3.6.0 |
| splines | splines | /usr/lib/R/library | 3.6.0 | base | NA | graphics, stats | NA | Matrix, methods | NA | Part of R 3.6.0 | NA | NA | NA | NA | yes | 3.6.0 |
| stats | stats | /usr/lib/R/library | 3.6.0 | base | NA | utils, grDevices, graphics | NA | MASS, Matrix, SuppDists, methods, stats4 | NA | Part of R 3.6.0 | NA | NA | NA | NA | yes | 3.6.0 |
| stats4 | stats4 | /usr/lib/R/library | 3.6.0 | base | NA | graphics, methods, stats | NA | NA | NA | Part of R 3.6.0 | NA | NA | NA | NA | NA | 3.6.0 |
| survival | survival | /usr/lib/R/library | 2.44-1.1 | recommended | R (>= 2.13.0) | graphics, Matrix, methods, splines, stats, utils | NA | NA | NA | LGPL (>= 2) | NA | NA | NA | NA | yes | 3.6.0 |
| tcltk | tcltk | /usr/lib/R/library | 3.6.0 | base | NA | utils | NA | NA | NA | Part of R 3.6.0 | NA | NA | NA | NA | yes | 3.6.0 |
| tools | tools | /usr/lib/R/library | 3.6.0 | base | NA | NA | NA | codetools, methods, xml2, curl, commonmark | NA | Part of R 3.6.0 | NA | NA | NA | NA | yes | 3.6.0 |
| utils | utils | /usr/lib/R/library | 3.6.0 | base | NA | NA | NA | methods, xml2, commonmark | NA | Part of R 3.6.0 | NA | NA | NA | NA | yes | 3.6.0 |
You can install new packages using the command install.packages()
[7]:
install.packages("auk", lib = "~/work")
[8]:
.libPaths("~/work")
library(auk)
auk 0.3.3 is designed for EBD files downloaded after 2018-08-15.
No EBD data directory set, see ?auk_set_ebd_path to set EBD_PATH
eBird taxonomy version: 2018
[9]:
remove.packages("auk")
Removing package from ‘/home/jovyan/work’
(as ‘lib’ is unspecified)
BioConductor¶
CRAN is home to many, many R packages. But there is a whole other world out there when it comes to bioinformatics in R. It’s called BioConductor. BioConductor is a comprehensive toolkit for all things having to do with high-throughput sequencing data processing and analysis. In this course, we will use the BioConductor package DESeq2 to perform differential expression analysis. It’s the end of the pipeline, after QC, clipping and trimming, aligning and
counting.
Installing BioConductor packages¶
BioConductor has it’s own installation procedure (and it’s own criteria for documentation, testing, etc.) - separate from CRAN. Let’s have a look at the page for DESeq2
[10]:
#source("https://bioconductor.org/biocLite.R")
#biocLite("DESeq2")
DESeq2 and S4 Objects¶
We’ll walk through an example using a sample data set called ‘airway’. Airway is an object of type ‘SummarizedExperiment’. This kind of object is the basis for many objects used in Bioconductor packages.
[11]:
library("airway")
data("airway")
se <- airway
Loading required package: SummarizedExperiment
Loading required package: GenomicRanges
Loading required package: stats4
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:dplyr’:
combine, intersect, setdiff, union
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
Loading required package: S4Vectors
Attaching package: ‘S4Vectors’
The following objects are masked from ‘package:dplyr’:
first, rename
The following object is masked from ‘package:base’:
expand.grid
Loading required package: IRanges
Attaching package: ‘IRanges’
The following objects are masked from ‘package:dplyr’:
collapse, desc, slice
Loading required package: GenomeInfoDb
Loading required package: Biobase
Welcome to Bioconductor
Vignettes contain introductory material; view with
'browseVignettes()'. To cite Bioconductor, see
'citation("Biobase")', and for packages 'citation("pkgname")'.
Loading required package: DelayedArray
Loading required package: matrixStats
Attaching package: ‘matrixStats’
The following objects are masked from ‘package:Biobase’:
anyMissing, rowMedians
The following object is masked from ‘package:dplyr’:
count
Loading required package: BiocParallel
Attaching package: ‘DelayedArray’
The following objects are masked from ‘package:matrixStats’:
colMaxs, colMins, colRanges, rowMaxs, rowMins, rowRanges
The following objects are masked from ‘package:base’:
aperm, apply, rowsum
[12]:
str(se)
Formal class 'RangedSummarizedExperiment' [package "SummarizedExperiment"] with 6 slots
..@ rowRanges :Formal class 'GRangesList' [package "GenomicRanges"] with 5 slots
.. .. ..@ unlistData :Formal class 'GRanges' [package "GenomicRanges"] with 7 slots
Warning message:
“Not a validObject(): no slot of name "elementType" for this object of class "GRanges"”
.. .. .. .. ..@ seqnames :Formal class 'Rle' [package "S4Vectors"] with 4 slots
.. .. .. .. .. .. ..@ values : Factor w/ 722 levels "1","2","3","4",..: 23 20 1 6 1 23 6 3 7 12 ...
.. .. .. .. .. .. ..@ lengths : int [1:47916] 27 29 173 80 75 27 4 41 196 71 ...
.. .. .. .. .. .. ..@ elementMetadata: NULL
.. .. .. .. .. .. ..@ metadata : list()
.. .. .. .. ..@ strand :Formal class 'Rle' [package "S4Vectors"] with 4 slots
.. .. .. .. .. .. ..@ values : Factor w/ 3 levels "+","-","*": 2 1 2 1 2 1 2 1 2 1 ...
.. .. .. .. .. .. ..@ lengths : int [1:31658] 17 10 59 72 26 45 68 12 42 33 ...
.. .. .. .. .. .. ..@ elementMetadata: NULL
.. .. .. .. .. .. ..@ metadata : list()
.. .. .. .. ..@ ranges :Formal class 'IRanges' [package "IRanges"] with 6 slots
.. .. .. .. .. .. ..@ start : int [1:745593] 99883667 99885756 99887482 99887538 99888402 99888402 99888439 99888928 99888928 99890175 ...
.. .. .. .. .. .. ..@ width : int [1:745593] 1317 108 84 28 135 135 98 99 99 75 ...
.. .. .. .. .. .. ..@ NAMES : NULL
.. .. .. .. .. .. ..@ elementType : chr "integer"
.. .. .. .. .. .. ..@ elementMetadata: NULL
.. .. .. .. .. .. ..@ metadata : list()
.. .. .. .. ..@ elementMetadata:Formal class 'DataFrame' [package "IRanges"] with 6 slots
.. .. .. .. .. .. ..@ rownames : NULL
.. .. .. .. .. .. ..@ nrows : int 745593
.. .. .. .. .. .. ..@ listData :List of 2
.. .. .. .. .. .. .. ..$ exon_id : int [1:745593] 667145 667146 667147 667148 667149 667150 667151 667153 667152 667154 ...
.. .. .. .. .. .. .. ..$ exon_name: chr [1:745593] "ENSE00001459322" "ENSE00000868868" "ENSE00000401072" "ENSE00001849132" ...
.. .. .. .. .. .. ..@ elementType : chr "ANY"
.. .. .. .. .. .. ..@ elementMetadata: NULL
.. .. .. .. .. .. ..@ metadata : list()
.. .. .. .. ..@ seqinfo :Formal class 'Seqinfo' [package "GenomeInfoDb"] with 4 slots
.. .. .. .. .. .. ..@ seqnames : chr [1:722] "1" "2" "3" "4" ...
.. .. .. .. .. .. ..@ seqlengths : int [1:722] 249250621 243199373 198022430 191154276 180915260 171115067 159138663 146364022 141213431 135534747 ...
.. .. .. .. .. .. ..@ is_circular: logi [1:722] FALSE FALSE FALSE FALSE FALSE FALSE ...
.. .. .. .. .. .. ..@ genome : chr [1:722] NA NA NA NA ...
.. .. .. .. ..@ metadata : list()
.. .. .. .. ..@ NA : NULL
.. .. ..@ elementMetadata:Formal class 'DataFrame' [package "IRanges"] with 6 slots
.. .. .. .. ..@ rownames : NULL
.. .. .. .. ..@ nrows : int 64102
.. .. .. .. ..@ listData : Named list()
.. .. .. .. ..@ elementType : chr "ANY"
.. .. .. .. ..@ elementMetadata: NULL
.. .. .. .. ..@ metadata : list()
.. .. ..@ elementType : chr "GRanges"
.. .. ..@ metadata :List of 1
.. .. .. ..$ genomeInfo:List of 20
.. .. .. .. ..$ Db type : chr "TranscriptDb"
.. .. .. .. ..$ Supporting package : chr "GenomicFeatures"
.. .. .. .. ..$ Data source : chr "BioMart"
.. .. .. .. ..$ Organism : chr "Homo sapiens"
.. .. .. .. ..$ Resource URL : chr "www.biomart.org:80"
.. .. .. .. ..$ BioMart database : chr "ensembl"
.. .. .. .. ..$ BioMart database version : chr "ENSEMBL GENES 75 (SANGER UK)"
.. .. .. .. ..$ BioMart dataset : chr "hsapiens_gene_ensembl"
.. .. .. .. ..$ BioMart dataset description : chr "Homo sapiens genes (GRCh37.p13)"
.. .. .. .. ..$ BioMart dataset version : chr "GRCh37.p13"
.. .. .. .. ..$ Full dataset : chr "yes"
.. .. .. .. ..$ miRBase build ID : chr NA
.. .. .. .. ..$ transcript_nrow : chr "215647"
.. .. .. .. ..$ exon_nrow : chr "745593"
.. .. .. .. ..$ cds_nrow : chr "537555"
.. .. .. .. ..$ Db created by : chr "GenomicFeatures package from Bioconductor"
.. .. .. .. ..$ Creation time : chr "2014-07-10 14:55:55 -0400 (Thu, 10 Jul 2014)"
.. .. .. .. ..$ GenomicFeatures version at creation time: chr "1.17.9"
.. .. .. .. ..$ RSQLite version at creation time : chr "0.11.4"
.. .. .. .. ..$ DBSCHEMAVERSION : chr "1.0"
.. .. ..@ partitioning :Formal class 'PartitioningByEnd' [package "IRanges"] with 5 slots
.. .. .. .. ..@ end : int [1:64102] 17 27 56 86 158 184 229 243 297 309 ...
.. .. .. .. ..@ NAMES : chr [1:64102] "ENSG00000000003" "ENSG00000000005" "ENSG00000000419" "ENSG00000000457" ...
.. .. .. .. ..@ elementType : chr "integer"
.. .. .. .. ..@ elementMetadata: NULL
.. .. .. .. ..@ metadata : list()
..@ colData :Formal class 'DataFrame' [package "IRanges"] with 6 slots
.. .. ..@ rownames : chr [1:8] "SRR1039508" "SRR1039509" "SRR1039512" "SRR1039513" ...
.. .. ..@ nrows : int 8
.. .. ..@ listData :List of 9
.. .. .. ..$ SampleName: Factor w/ 8 levels "GSM1275862","GSM1275863",..: 1 2 3 4 5 6 7 8
.. .. .. ..$ cell : Factor w/ 4 levels "N052611","N061011",..: 4 4 1 1 3 3 2 2
.. .. .. ..$ dex : Factor w/ 2 levels "trt","untrt": 2 1 2 1 2 1 2 1
.. .. .. ..$ albut : Factor w/ 1 level "untrt": 1 1 1 1 1 1 1 1
.. .. .. ..$ Run : Factor w/ 8 levels "SRR1039508","SRR1039509",..: 1 2 3 4 5 6 7 8
.. .. .. ..$ avgLength : int [1:8] 126 126 126 87 120 126 101 98
.. .. .. ..$ Experiment: Factor w/ 8 levels "SRX384345","SRX384346",..: 1 2 3 4 5 6 7 8
.. .. .. ..$ Sample : Factor w/ 8 levels "SRS508567","SRS508568",..: 2 1 3 4 5 6 7 8
.. .. .. ..$ BioSample : Factor w/ 8 levels "SAMN02422669",..: 1 4 6 2 7 3 8 5
.. .. ..@ elementType : chr "ANY"
.. .. ..@ elementMetadata: NULL
.. .. ..@ metadata : list()
..@ assays :Reference class 'ShallowSimpleListAssays' [package "GenomicRanges"] with 1 field
.. ..$ data: NULL
.. ..and 12 methods.
..@ NAMES : NULL
..@ elementMetadata:Formal class 'DataFrame' [package "S4Vectors"] with 6 slots
.. .. ..@ rownames : NULL
.. .. ..@ nrows : int 64102
.. .. ..@ listData : Named list()
.. .. ..@ elementType : chr "ANY"
.. .. ..@ elementMetadata: NULL
.. .. ..@ metadata : list()
..@ metadata :List of 1
.. ..$ :Formal class 'MIAME' [package "Biobase"] with 13 slots
.. .. .. ..@ name : chr "Himes BE"
.. .. .. ..@ lab : chr NA
.. .. .. ..@ contact : chr ""
.. .. .. ..@ title : chr "RNA-Seq transcriptome profiling identifies CRISPLD2 as a glucocorticoid responsive gene that modulates cytokine"| __truncated__
.. .. .. ..@ abstract : chr "Asthma is a chronic inflammatory respiratory disease that affects over 300 million people worldwide. Glucocorti"| __truncated__
.. .. .. ..@ url : chr "http://www.ncbi.nlm.nih.gov/pubmed/24926665"
.. .. .. ..@ pubMedIds : chr "24926665"
.. .. .. ..@ samples : list()
.. .. .. ..@ hybridizations : list()
.. .. .. ..@ normControls : list()
.. .. .. ..@ preprocessing : list()
.. .. .. ..@ other : list()
.. .. .. ..@ .__classVersion__:Formal class 'Versions' [package "Biobase"] with 1 slot
.. .. .. .. .. ..@ .Data:List of 2
.. .. .. .. .. .. ..$ : int [1:3] 1 0 0
.. .. .. .. .. .. ..$ : int [1:3] 1 1 0
This tutorial gives a great introduction to the SummarizedExperiment object. We’ll take a peek, and then move on to DESeq2
[13]:
assays(se)
List of length 1
names(1): counts
[14]:
assays(se)$counts
| SRR1039508 | SRR1039509 | SRR1039512 | SRR1039513 | SRR1039516 | SRR1039517 | SRR1039520 | SRR1039521 | |
|---|---|---|---|---|---|---|---|---|
| ENSG00000000003 | 679 | 448 | 873 | 408 | 1138 | 1047 | 770 | 572 |
| ENSG00000000005 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| ENSG00000000419 | 467 | 515 | 621 | 365 | 587 | 799 | 417 | 508 |
| ENSG00000000457 | 260 | 211 | 263 | 164 | 245 | 331 | 233 | 229 |
| ENSG00000000460 | 60 | 55 | 40 | 35 | 78 | 63 | 76 | 60 |
| ENSG00000000938 | 0 | 0 | 2 | 0 | 1 | 0 | 0 | 0 |
| ENSG00000000971 | 3251 | 3679 | 6177 | 4252 | 6721 | 11027 | 5176 | 7995 |
| ENSG00000001036 | 1433 | 1062 | 1733 | 881 | 1424 | 1439 | 1359 | 1109 |
| ENSG00000001084 | 519 | 380 | 595 | 493 | 820 | 714 | 696 | 704 |
| ENSG00000001167 | 394 | 236 | 464 | 175 | 658 | 584 | 360 | 269 |
| ENSG00000001460 | 172 | 168 | 264 | 118 | 241 | 210 | 155 | 177 |
| ENSG00000001461 | 2112 | 1867 | 5137 | 2657 | 2735 | 2751 | 2467 | 2905 |
| ENSG00000001497 | 524 | 488 | 638 | 357 | 676 | 806 | 493 | 475 |
| ENSG00000001561 | 71 | 51 | 211 | 156 | 23 | 38 | 134 | 172 |
| ENSG00000001617 | 555 | 394 | 905 | 415 | 727 | 697 | 618 | 599 |
| ENSG00000001626 | 10 | 2 | 9 | 2 | 10 | 6 | 5 | 5 |
| ENSG00000001629 | 1660 | 1251 | 2259 | 1079 | 2462 | 2514 | 1888 | 1660 |
| ENSG00000001630 | 59 | 54 | 66 | 23 | 84 | 87 | 31 | 59 |
| ENSG00000001631 | 729 | 692 | 943 | 475 | 1034 | 1163 | 731 | 744 |
| ENSG00000002016 | 201 | 161 | 256 | 99 | 268 | 257 | 160 | 137 |
| ENSG00000002079 | 3 | 0 | 3 | 1 | 4 | 0 | 0 | 1 |
| ENSG00000002330 | 206 | 174 | 184 | 111 | 194 | 260 | 156 | 177 |
| ENSG00000002549 | 1459 | 1294 | 1317 | 998 | 1451 | 1824 | 853 | 1031 |
| ENSG00000002586 | 7507 | 7203 | 9501 | 6214 | 10973 | 12863 | 6834 | 7225 |
| ENSG00000002587 | 2 | 0 | 1 | 0 | 0 | 2 | 0 | 0 |
| ENSG00000002726 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
| ENSG00000002745 | 4 | 6 | 22 | 10 | 2 | 1 | 5 | 3 |
| ENSG00000002746 | 151 | 139 | 117 | 65 | 90 | 102 | 86 | 119 |
| ENSG00000002822 | 411 | 303 | 446 | 195 | 445 | 523 | 295 | 300 |
| ENSG00000002834 | 6314 | 6364 | 7831 | 5809 | 6677 | 11970 | 5766 | 7825 |
| ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ |
| LRG_70 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_71 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_715 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_717 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_72 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_73 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_74 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_75 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_76 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_77 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_78 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_79 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_8 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_80 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_81 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_83 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_84 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_85 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_86 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_88 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_89 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_90 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_91 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_92 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_93 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_94 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_96 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_98 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| LRG_99 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
[15]:
rowRanges(se)
GRangesList object of length 64102:
$ENSG00000000003
GRanges object with 17 ranges and 2 metadata columns:
seqnames ranges strand | exon_id exon_name
<Rle> <IRanges> <Rle> | <integer> <character>
[1] X 99883667-99884983 - | 667145 ENSE00001459322
[2] X 99885756-99885863 - | 667146 ENSE00000868868
[3] X 99887482-99887565 - | 667147 ENSE00000401072
[4] X 99887538-99887565 - | 667148 ENSE00001849132
[5] X 99888402-99888536 - | 667149 ENSE00003554016
... ... ... ... . ... ...
[13] X 99890555-99890743 - | 667156 ENSE00003512331
[14] X 99891188-99891686 - | 667158 ENSE00001886883
[15] X 99891605-99891803 - | 667159 ENSE00001855382
[16] X 99891790-99892101 - | 667160 ENSE00001863395
[17] X 99894942-99894988 - | 667161 ENSE00001828996
...
<64101 more elements>
-------
seqinfo: 722 sequences (1 circular) from an unspecified genome
[16]:
colData(se)
DataFrame with 8 rows and 9 columns
SampleName cell dex albut Run avgLength
<factor> <factor> <factor> <factor> <factor> <integer>
SRR1039508 GSM1275862 N61311 untrt untrt SRR1039508 126
SRR1039509 GSM1275863 N61311 trt untrt SRR1039509 126
SRR1039512 GSM1275866 N052611 untrt untrt SRR1039512 126
SRR1039513 GSM1275867 N052611 trt untrt SRR1039513 87
SRR1039516 GSM1275870 N080611 untrt untrt SRR1039516 120
SRR1039517 GSM1275871 N080611 trt untrt SRR1039517 126
SRR1039520 GSM1275874 N061011 untrt untrt SRR1039520 101
SRR1039521 GSM1275875 N061011 trt untrt SRR1039521 98
Experiment Sample BioSample
<factor> <factor> <factor>
SRR1039508 SRX384345 SRS508568 SAMN02422669
SRR1039509 SRX384346 SRS508567 SAMN02422675
SRR1039512 SRX384349 SRS508571 SAMN02422678
SRR1039513 SRX384350 SRS508572 SAMN02422670
SRR1039516 SRX384353 SRS508575 SAMN02422682
SRR1039517 SRX384354 SRS508576 SAMN02422673
SRR1039520 SRX384357 SRS508579 SAMN02422683
SRR1039521 SRX384358 SRS508580 SAMN02422677
[17]:
metadata(se)
[[1]]
Experiment data
Experimenter name: Himes BE
Laboratory: NA
Contact information:
Title: RNA-Seq transcriptome profiling identifies CRISPLD2 as a glucocorticoid responsive gene that modulates cytokine function in airway smooth muscle cells.
URL: http://www.ncbi.nlm.nih.gov/pubmed/24926665
PMIDs: 24926665
Abstract: A 226 word abstract is available. Use 'abstract' method.
[18]:
# Just a list - we can add elements
metadata(se)$formula <- counts ~ dex + albut
metadata(se)
[[1]]
Experiment data
Experimenter name: Himes BE
Laboratory: NA
Contact information:
Title: RNA-Seq transcriptome profiling identifies CRISPLD2 as a glucocorticoid responsive gene that modulates cytokine function in airway smooth muscle cells.
URL: http://www.ncbi.nlm.nih.gov/pubmed/24926665
PMIDs: 24926665
Abstract: A 226 word abstract is available. Use 'abstract' method.
$formula
counts ~ dex + albut
[19]:
# subset the first five transcripts and first three samples
se[1:5, 1:3]
class: RangedSummarizedExperiment
dim: 5 3
metadata(2): '' formula
assays(1): counts
rownames(5): ENSG00000000003 ENSG00000000005 ENSG00000000419
ENSG00000000457 ENSG00000000460
rowData names(0):
colnames(3): SRR1039508 SRR1039509 SRR1039512
colData names(9): SampleName cell ... Sample BioSample
[20]:
assays(se[1:5,1:3])$counts
| SRR1039508 | SRR1039509 | SRR1039512 | |
|---|---|---|---|
| ENSG00000000003 | 679 | 448 | 873 |
| ENSG00000000005 | 0 | 0 | 0 |
| ENSG00000000419 | 467 | 515 | 621 |
| ENSG00000000457 | 260 | 211 | 263 |
| ENSG00000000460 | 60 | 55 | 40 |
[21]:
library("DESeq2")
dds <- DESeqDataSet(se, design = ~ cell + dex)
dds
Registered S3 methods overwritten by 'ggplot2':
method from
[.quosures rlang
c.quosures rlang
print.quosures rlang
class: DESeqDataSet
dim: 64102 8
metadata(3): '' formula version
assays(1): counts
rownames(64102): ENSG00000000003 ENSG00000000005 ... LRG_98 LRG_99
rowData names(0):
colnames(8): SRR1039508 SRR1039509 ... SRR1039520 SRR1039521
colData names(9): SampleName cell ... Sample BioSample
[22]:
# remove rows with less than 10 total transcripts
keep <- rowSums(counts(dds)) >= 10
dds <- dds[keep,]
[23]:
colData(dds)
DataFrame with 8 rows and 9 columns
SampleName cell dex albut Run avgLength
<factor> <factor> <factor> <factor> <factor> <integer>
SRR1039508 GSM1275862 N61311 untrt untrt SRR1039508 126
SRR1039509 GSM1275863 N61311 trt untrt SRR1039509 126
SRR1039512 GSM1275866 N052611 untrt untrt SRR1039512 126
SRR1039513 GSM1275867 N052611 trt untrt SRR1039513 87
SRR1039516 GSM1275870 N080611 untrt untrt SRR1039516 120
SRR1039517 GSM1275871 N080611 trt untrt SRR1039517 126
SRR1039520 GSM1275874 N061011 untrt untrt SRR1039520 101
SRR1039521 GSM1275875 N061011 trt untrt SRR1039521 98
Experiment Sample BioSample
<factor> <factor> <factor>
SRR1039508 SRX384345 SRS508568 SAMN02422669
SRR1039509 SRX384346 SRS508567 SAMN02422675
SRR1039512 SRX384349 SRS508571 SAMN02422678
SRR1039513 SRX384350 SRS508572 SAMN02422670
SRR1039516 SRX384353 SRS508575 SAMN02422682
SRR1039517 SRX384354 SRS508576 SAMN02422673
SRR1039520 SRX384357 SRS508579 SAMN02422683
SRR1039521 SRX384358 SRS508580 SAMN02422677
[24]:
# Specify reference level
dds$dex <- factor(dds$dex, levels = c("untrt","trt"))
#alternative
dds$dex <- relevel(dds$dex, ref = "untrt")
[25]:
ddsDE <- DESeq(dds)
res <- results(ddsDE)
res
estimating size factors
estimating dispersions
gene-wise dispersion estimates
mean-dispersion relationship
final dispersion estimates
fitting model and testing
log2 fold change (MLE): dex trt vs untrt
Wald test p-value: dex trt vs untrt
DataFrame with 22369 rows and 6 columns
baseMean log2FoldChange lfcSE
<numeric> <numeric> <numeric>
ENSG00000000003 708.597861536998 -0.381227063105246 0.100702281802452
ENSG00000000419 520.296296925274 0.206840376248021 0.112107724670949
ENSG00000000457 237.162103834464 0.037954335389843 0.142823085130162
ENSG00000000460 57.9323803212894 -0.0885309218770955 0.284934403160848
ENSG00000000971 5817.31081674539 0.42642455731918 0.0888056149171329
... ... ... ...
ENSG00000273483 2.68955174874763 0.84920766214805 1.25336471679961
ENSG00000273485 1.28646279725438 -0.123613168835481 1.58825060361379
ENSG00000273486 15.4524429107135 -0.150428542992948 0.482097671940096
ENSG00000273487 8.16326862804303 1.04563935414612 0.693057045984001
ENSG00000273488 8.58437098976254 0.108945615633239 0.632299687532417
stat pvalue padj
<numeric> <numeric> <numeric>
ENSG00000000003 -3.78568445800561 0.000153286080966785 0.0012892045764893
ENSG00000000419 1.84501448811957 0.065035431092294 0.194929521562025
ENSG00000000457 0.265743702114076 0.790436603689371 0.909899502487793
ENSG00000000460 -0.310706327123015 0.756023886827025 0.89299357560032
ENSG00000000971 4.80177472693691 1.57265558148175e-06 2.06391014885582e-05
... ... ... ...
ENSG00000273483 0.677542339245393 0.498061916323377 NA
ENSG00000273485 -0.0778297634858257 0.937963470414454 NA
ENSG00000273486 -0.312029183604188 0.755018344483373 0.892519390830221
ENSG00000273487 1.50873490170137 0.131366542567104 0.323297597320869
ENSG00000273488 0.172300600144854 0.863201212561737 0.943414817499248