importFromSE: Convenient import from a SummarizedExperiment object

Description Usage Arguments Details Value Author(s) Examples

View source: R/importFromSE.R

Description

Import a summarizedExperiment object containing expression data at different times.

Usage

1
importFromSE(se, sample, SE_byTime = FALSE)

Arguments

se

SummarizedExperiment. Where assays slot can be organized either by samples or by times.

sample

Numeric or character. Sample identifier. See details and vignette

SE_byTime

Logical. Default FALSE. Indicates whether the data is organized by sample or by time.

Details

This function enables the integration of an object of the summarizedExpmeriment class and is integrated into all other functions, so there is no need to run it in an isolated way. There are two possible organization options in the slot assays. A) each row is a gene each column, is a sample and each matrix is a time. In this case SE_byTime=FALSE. B) each row is a gene , each column is a time and each matrix is a sample. In this case SE_byTime= TRUE. This concept is illustrated in package vignette.

Value

Sample data frame where rows are genes and columns are times.,

Author(s)

Fernando Pérez-Sanz (fernando.perez8@um.es)

Miriam Riquelme-Pérez (miriam.riquelmep@gmail.com)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Each matrix one time / each column one sample (SE_byTime=FALSE)
# Code to create dummy data

nrows <- 200
ncols <- 6
time1 <- matrix(runif(nrows * ncols, 1, 1e4), nrows)
time2 <- matrix(runif(nrows * ncols, 1, 1e4), nrows)
rowRanges <- GenomicRanges::GRanges(rep(c("chr1", "chr2"), c(50, 150)),
                     IRanges::IRanges(floor(runif(200, 1e5, 1e6)), width=100),
                                          strand=sample(c("+", "-"), 200, TRUE),
                                          feature_id=sprintf("ID%03d", 1:200))
colData <- S4Vectors::DataFrame(Treatment=rep(c("ChIP", "Input"), 3),
                      Samples = LETTERS[1:6],
                      row.names=LETTERS[1:6])
se <- SummarizedExperiment::SummarizedExperiment(assays=list(time1=time1, time2=time2),
                      rowRanges=rowRanges, colData=colData)

# Get sample "A" with all times

importFromSE(se, sample="A", SE_byTime = FALSE)

# or sample = 1 because is first columns in each matrix (each time)

# Each matrix one sample / each column one time (SE_byTime=TRUE)
# Code to create dummy data

nrows <- 200
ncols <- 6
sampleA <- matrix(runif(nrows * ncols, 1, 1e4), nrows)
sampleB <- matrix(runif(nrows * ncols, 1, 1e4), nrows)
rowRanges <- GenomicRanges::GRanges(rep(c("chr1", "chr2"), c(50, 150)),
                     IRanges::IRanges(floor(runif(200, 1e5, 1e6)), width=100),
                                          strand=sample(c("+", "-"), 200, TRUE),
                                          feature_id=sprintf("ID%03d", 1:200))
 colData <- S4Vectors::DataFrame(Time=paste("time",seq(1:6), sep=""),
                      sampleA = rep("A",6),
                      sampleB = rep("B", 6),
                      row.names = paste("time",seq(1:6), sep=""))
se <- SummarizedExperiment::SummarizedExperiment(assays=list(sampleA=sampleA, sampleB=sampleB),
                      rowRanges=rowRanges, colData=colData)
# Get sample "sampleA" with all times

importFromSE(se, sample=1, SE_byTime = TRUE)

# or sample = 1 because is the first matrix in assays structure.

fpsanz/tscR documentation built on July 17, 2020, 2:20 a.m.