## ------------------------------------------------------------------------ dir <- system.file("extdata/salmon_dm", package="tximportData") # here gzipped, normally these are not files <- file.path(dir, "SRR1197474_cdna", "quant.sf.gz") file.exists(files) coldata <- data.frame(files, names="SRR1197474", condition="A", stringsAsFactors=FALSE) coldata ## ----eval=FALSE---------------------------------------------------------- # library(tximeta) # se <- tximeta(coldata) ## ------------------------------------------------------------------------ dir <- system.file("extdata", package="tximeta") indexDir <- file.path(dir, "Drosophila_melanogaster.BDGP6.cdna.v92_salmon_0.10.2") fastaFTP <- "ftp://ftp.ensembl.org/pub/release-92/fasta/drosophila_melanogaster/cdna/Drosophila_melanogaster.BDGP6.cdna.all.fa.gz" dir2 <- system.file("extdata/salmon_dm", package="tximportData") gtfPath <- file.path(dir2,"Drosophila_melanogaster.BDGP6.92.gtf.gz") suppressPackageStartupMessages(library(tximeta)) makeLinkedTxome(indexDir=indexDir, source="Ensembl", organism="Drosophila melanogaster", release="92", genome="BDGP6", fasta=fastaFTP, gtf=gtfPath, write=FALSE) ## ------------------------------------------------------------------------ library(tximeta) se <- tximeta(coldata) ## ------------------------------------------------------------------------ suppressPackageStartupMessages(library(SummarizedExperiment)) colData(se) ## ------------------------------------------------------------------------ assayNames(se) ## ------------------------------------------------------------------------ rowRanges(se) ## ------------------------------------------------------------------------ seqinfo(se) ## ------------------------------------------------------------------------ gse <- summarizeToGene(se) rowRanges(gse) ## ------------------------------------------------------------------------ library(org.Dm.eg.db) gse <- addIds(gse, "REFSEQ", gene=TRUE) mcols(gse) ## ------------------------------------------------------------------------ suppressPackageStartupMessages(library(DESeq2)) # here there is a single sample so we use ~1. # expect a warning that there is only a single sample... suppressWarnings({dds <- DESeqDataSet(gse, ~1)}) dds <- estimateSizeFactors(dds) # ... and so on ## ------------------------------------------------------------------------ suppressPackageStartupMessages(library(edgeR)) cts <- assays(gse)[["counts"]] normMat <- assays(gse)[["length"]] normMat <- normMat / exp(rowMeans(log(normMat))) o <- log(calcNormFactors(cts/normMat)) + log(colSums(cts/normMat)) y <- DGEList(cts) y <- scaleOffset(y, t(t(log(normMat)) + o)) # ... see edgeR User's Guide for further steps ## ------------------------------------------------------------------------ names(metadata(se)) str(metadata(se)[["quantInfo"]]) str(metadata(se)[["txomeInfo"]]) str(metadata(se)[["tximetaInfo"]]) str(metadata(se)[["txdbInfo"]]) ## ------------------------------------------------------------------------ dir <- system.file("extdata/salmon_dm/SRR1197474", package="tximportData") file <- file.path(dir, "quant.sf.gz") file.exists(file) coldata <- data.frame(files=file, names="SRR1197474", sample="1", stringsAsFactors=FALSE) ## ------------------------------------------------------------------------ se <- tximeta(coldata) ## ------------------------------------------------------------------------ dir <- system.file("extdata", package="tximeta") indexDir <- file.path(dir, "Drosophila_melanogaster.BDGP6.v92_salmon_0.10.2") ## ------------------------------------------------------------------------ fastaFTP <- c("ftp://ftp.ensembl.org/pub/release-92/fasta/drosophila_melanogaster/cdna/Drosophila_melanogaster.BDGP6.cdna.all.fa.gz", "ftp://ftp.ensembl.org/pub/release-92/fasta/drosophila_melanogaster/ncrna/Drosophila_melanogaster.BDGP6.ncrna.fa.gz") #gtfFTP <- "ftp://ftp.ensembl.org/pub/release-92/gtf/drosophila_melanogaster/Drosophila_melanogaster.BDGP6.92.gtf.gz" ## ------------------------------------------------------------------------ dir2 <- system.file("extdata/salmon_dm", package="tximportData") gtfPath <- file.path(dir2,"Drosophila_melanogaster.BDGP6.92.gtf.gz") ## ------------------------------------------------------------------------ tmp <- tempdir() jsonFile <- file.path(tmp, paste0(basename(indexDir), ".json")) makeLinkedTxome(indexDir=indexDir, source="Ensembl", organism="Drosophila melanogaster", release="92", genome="BDGP6", fasta=fastaFTP, gtf=gtfPath, jsonFile=jsonFile) ## ------------------------------------------------------------------------ se <- tximeta(coldata) ## ------------------------------------------------------------------------ rowRanges(se) seqinfo(se) ## ------------------------------------------------------------------------ library(BiocFileCache) if (interactive()) { bfcloc <- getTximetaBFC() } else { bfcloc <- tempdir() } bfc <- BiocFileCache(bfcloc) bfcinfo(bfc) bfcremove(bfc, bfcquery(bfc, "linkedTxomeTbl")$rid) bfcinfo(bfc) ## ------------------------------------------------------------------------ jsonFile <- file.path(tmp, paste0(basename(indexDir), ".json")) loadLinkedTxome(jsonFile) ## ------------------------------------------------------------------------ se <- tximeta(coldata) ## ------------------------------------------------------------------------ if (interactive()) { bfcloc <- getTximetaBFC() } else { bfcloc <- tempdir() } bfc <- BiocFileCache(bfcloc) bfcinfo(bfc) bfcremove(bfc, bfcquery(bfc, "linkedTxomeTbl")$rid) bfcinfo(bfc) ## ------------------------------------------------------------------------ library(devtools) session_info()