R/importDeeptoolsExperiment.R
importDeeptoolsExperiment.RdImport a deepTools Matrix File as a SummarizedExperiment Object
importDeeptoolsExperiment(file, col.names = NULL)
| file | A gzip-compressed matrix file. |
|---|---|
| col.names | A character vector of column names immediately set on the output object. |
A SummarizedExperiment object. See Details.
Matrix files produced by deepTools do not include column names that are useful to indicate the genomic position relative to a reference point, for instance.
While colnames could be manually set by users on the SummarizedExperiment returned, it can be convenient to provide a set of column names directly to the importDeeptoolsExperiment() function, especially when importing multiple samples in an lapply() statement, for instance.
The returned object contains:
The deepTools matrix in the assay slot.
The genomic range information in the rowRanges slot.
library(rtracklayer) library(GenomicRanges) # Prepare example data ---- se_list <- generateDeeptoolsExperiments(ranges=20, bins=10, names=c("A")) se_list#> $A #> class: RangedSummarizedExperiment #> dim: 20 10 #> metadata(0): #> assays(1): matrix #> rownames(20): GR_1 GR_2 ... GR_19 GR_20 #> rowData names(0): #> colnames(10): 1 2 ... 9 10 #> colData names(0): #># Write example file ---- se_A <- se_list[["A"]] gr_A <- rowRanges(se_A) df_A <- data.frame( seqnames(gr_A), start(gr_A), end(gr_A), names(gr_A), 0, strand(gr_A), assay(se_A)) # Write the sample data to file tf <- tempfile(fileext=".matrix.gz") conn <- gzfile(tf, "wt") write.table(df_A, conn, row.names=FALSE, col.names=TRUE) close(conn) # Usage ---- importDeeptoolsExperiment(tf)#> class: RangedSummarizedExperiment #> dim: 20 10 #> metadata(0): #> assays(1): matrix #> rownames(20): GR_1 GR_2 ... GR_19 GR_20 #> rowData names(0): #> colnames(10): 1 2 ... 9 10 #> colData names(0):