Last data update: 2014.03.03
R: Convert to other classes
Convert to other classes
Description
Convert a SCESet object into other classes for entry into other analysis pipelines.
Usage
## S4 method for signature 'SCESet'
convertTo(x, type=c("edgeR", "DESeq2", "monocle"),
fData.col=NULL, pData.col=NULL, ...,
assay, normalize=TRUE, get.spikes=FALSE)
Arguments
x
A SCESet object.
type
A string specifying the analysis for which the object should be prepared.
fData.col
Any set of indices specifying which columns of fData(x)
should be retained in the returned object.
pData.col
Any set of indices specifying which columns of pData(x)
should be retained.
...
Other arguments to be passed to pipeline-specific constructors.
assay
A string specifying which assay of x
should be put in the returned object.
normalize
A logical scalar specifying whether the assay values should be normalized for type="monocle"
.
get.spikes
A logical scalar specifying whether rows corresponding to spike-in transcripts should be returned.
Details
This function converts a SCESet into various other classes in preparation for entry into other analysis pipelines, as specified by type
.
Gene- and cell-specific data fields can be retained in the output object by setting fData.col
and pData.col
, respectively.
Other arguments can be passed to the relevant constructors through the ellipsis.
By default, for edgeR and DESeq2, assay
is set to "counts"
such that count data is stored in the output object.
This is consistent with the required inputs to these analysis pipeline (normalization information is stored through size factors).
For monocle, counts are divided by the size factors to yield (roughly) log-normally distributed expression values.
This can be turned off (i.e., to use the raw values in assay
) by setting normalize=FALSE
.
In all cases, rows corresponding to spike-in transcripts are removed from the output object by default.
As such, rows in the returned object may not correspond directly to rows in x
.
Users should consider this when retrieving analysis results from these pipelines, e.g., match on row names.
This behaviour can be turned off by setting get.spikes=TRUE
, such that all rows are retrieved in the output object.
Value
For type="edgeR"
, a DGEList object is returned containing the count matrix.
Size factors are converted to normalization factors.
Gene-specific fData
is stored in the genes
element, and cell-specific pData
is stored in the samples
element.
For type="DESeq2"
, a DESeqDataSet object is returned containing the count matrix and size factors.
Additional gene- and cell-specific data is stored in the mcols
and colData
respectively.
For type="monocle"
, a CellDataSet object is returned containing the unlogged expression values.
Additional gene- and cell-specific data is stored in the fData
and pData
respectively.
Author(s)
Aaron Lun
See Also
DGEList
,
DESeqDataSetFromMatrix
,
newCellDataSet
Examples
ncells <- 200
ngenes <- 100
count.sizes <- rnbinom(ncells, mu=100, size=5)
dummy <- matrix(count.sizes, ncol=ncells, nrow=ngenes, byrow=TRUE)
rownames(dummy) <- paste0("X", seq_len(ngenes))
X <- newSCESet(countData=data.frame(dummy))
is.spike <- rbinom(ngenes, 1, 0.5)==0L
isSpike(X) <- is.spike
sizeFactors(X) <- 2^rnorm(ncells)
X <- normalize(X)
fData(X)$SYMBOL <- paste0("X", seq_len(ngenes))
X$other <- sample(LETTERS, ncells, replace=TRUE)
convertTo(X, type="edgeR")
convertTo(X, type="DESeq2")
convertTo(X, type="monocle")
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(scran)
Loading required package: BiocParallel
Loading required package: scater
Loading required package: 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, xtabs
The following objects are masked from 'package:base':
Filter, Find, Map, Position, Reduce, anyDuplicated, append,
as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
rbind, rownames, sapply, setdiff, sort, table, tapply, union,
unique, unsplit
Welcome to Bioconductor
Vignettes contain introductory material; view with
'browseVignettes()'. To cite Bioconductor, see
'citation("Biobase")', and for packages 'citation("pkgname")'.
Loading required package: ggplot2
Attaching package: 'scater'
The following object is masked from 'package:stats':
filter
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/scran/convertTo.Rd_%03d_medium.png", width=480, height=480)
> ### Name: convertTo
> ### Title: Convert to other classes
> ### Aliases: convertTo convertTo,SCESet-method
>
> ### ** Examples
>
> ncells <- 200
> ngenes <- 100
> count.sizes <- rnbinom(ncells, mu=100, size=5)
> dummy <- matrix(count.sizes, ncol=ncells, nrow=ngenes, byrow=TRUE)
> rownames(dummy) <- paste0("X", seq_len(ngenes))
>
> X <- newSCESet(countData=data.frame(dummy))
> is.spike <- rbinom(ngenes, 1, 0.5)==0L
> isSpike(X) <- is.spike
> sizeFactors(X) <- 2^rnorm(ncells)
> X <- normalize(X)
>
> fData(X)$SYMBOL <- paste0("X", seq_len(ngenes))
> X$other <- sample(LETTERS, ncells, replace=TRUE)
>
> convertTo(X, type="edgeR")
An object of class "DGEList"
$counts
X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20
X2 40 76 65 129 106 74 166 37 58 123 42 136 115 290 89 35 116 52 114 87
X3 40 76 65 129 106 74 166 37 58 123 42 136 115 290 89 35 116 52 114 87
X4 40 76 65 129 106 74 166 37 58 123 42 136 115 290 89 35 116 52 114 87
X11 40 76 65 129 106 74 166 37 58 123 42 136 115 290 89 35 116 52 114 87
X12 40 76 65 129 106 74 166 37 58 123 42 136 115 290 89 35 116 52 114 87
X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 X32 X33 X34 X35 X36 X37 X38 X39
X2 90 130 130 224 108 159 119 55 126 36 123 56 202 96 100 43 88 110 80
X3 90 130 130 224 108 159 119 55 126 36 123 56 202 96 100 43 88 110 80
X4 90 130 130 224 108 159 119 55 126 36 123 56 202 96 100 43 88 110 80
X11 90 130 130 224 108 159 119 55 126 36 123 56 202 96 100 43 88 110 80
X12 90 130 130 224 108 159 119 55 126 36 123 56 202 96 100 43 88 110 80
X40 X41 X42 X43 X44 X45 X46 X47 X48 X49 X50 X51 X52 X53 X54 X55 X56 X57 X58
X2 73 267 59 112 128 102 47 86 98 156 119 118 62 68 179 58 36 82 30
X3 73 267 59 112 128 102 47 86 98 156 119 118 62 68 179 58 36 82 30
X4 73 267 59 112 128 102 47 86 98 156 119 118 62 68 179 58 36 82 30
X11 73 267 59 112 128 102 47 86 98 156 119 118 62 68 179 58 36 82 30
X12 73 267 59 112 128 102 47 86 98 156 119 118 62 68 179 58 36 82 30
X59 X60 X61 X62 X63 X64 X65 X66 X67 X68 X69 X70 X71 X72 X73 X74 X75 X76 X77
X2 177 144 52 99 129 121 101 81 149 129 78 132 81 123 70 93 99 105 67
X3 177 144 52 99 129 121 101 81 149 129 78 132 81 123 70 93 99 105 67
X4 177 144 52 99 129 121 101 81 149 129 78 132 81 123 70 93 99 105 67
X11 177 144 52 99 129 121 101 81 149 129 78 132 81 123 70 93 99 105 67
X12 177 144 52 99 129 121 101 81 149 129 78 132 81 123 70 93 99 105 67
X78 X79 X80 X81 X82 X83 X84 X85 X86 X87 X88 X89 X90 X91 X92 X93 X94 X95 X96
X2 97 95 58 34 212 52 155 69 79 80 273 44 70 52 187 115 110 40 115
X3 97 95 58 34 212 52 155 69 79 80 273 44 70 52 187 115 110 40 115
X4 97 95 58 34 212 52 155 69 79 80 273 44 70 52 187 115 110 40 115
X11 97 95 58 34 212 52 155 69 79 80 273 44 70 52 187 115 110 40 115
X12 97 95 58 34 212 52 155 69 79 80 273 44 70 52 187 115 110 40 115
X97 X98 X99 X100 X101 X102 X103 X104 X105 X106 X107 X108 X109 X110 X111
X2 81 70 107 157 103 93 20 122 106 96 40 76 82 148 81
X3 81 70 107 157 103 93 20 122 106 96 40 76 82 148 81
X4 81 70 107 157 103 93 20 122 106 96 40 76 82 148 81
X11 81 70 107 157 103 93 20 122 106 96 40 76 82 148 81
X12 81 70 107 157 103 93 20 122 106 96 40 76 82 148 81
X112 X113 X114 X115 X116 X117 X118 X119 X120 X121 X122 X123 X124 X125 X126
X2 136 102 78 47 50 75 96 24 126 188 94 119 81 138 105
X3 136 102 78 47 50 75 96 24 126 188 94 119 81 138 105
X4 136 102 78 47 50 75 96 24 126 188 94 119 81 138 105
X11 136 102 78 47 50 75 96 24 126 188 94 119 81 138 105
X12 136 102 78 47 50 75 96 24 126 188 94 119 81 138 105
X127 X128 X129 X130 X131 X132 X133 X134 X135 X136 X137 X138 X139 X140 X141
X2 42 120 89 143 90 91 162 41 106 80 175 87 76 76 46
X3 42 120 89 143 90 91 162 41 106 80 175 87 76 76 46
X4 42 120 89 143 90 91 162 41 106 80 175 87 76 76 46
X11 42 120 89 143 90 91 162 41 106 80 175 87 76 76 46
X12 42 120 89 143 90 91 162 41 106 80 175 87 76 76 46
X142 X143 X144 X145 X146 X147 X148 X149 X150 X151 X152 X153 X154 X155 X156
X2 89 80 41 88 82 86 86 78 205 112 150 89 157 62 111
X3 89 80 41 88 82 86 86 78 205 112 150 89 157 62 111
X4 89 80 41 88 82 86 86 78 205 112 150 89 157 62 111
X11 89 80 41 88 82 86 86 78 205 112 150 89 157 62 111
X12 89 80 41 88 82 86 86 78 205 112 150 89 157 62 111
X157 X158 X159 X160 X161 X162 X163 X164 X165 X166 X167 X168 X169 X170 X171
X2 151 24 117 81 122 50 36 154 46 103 48 43 93 74 46
X3 151 24 117 81 122 50 36 154 46 103 48 43 93 74 46
X4 151 24 117 81 122 50 36 154 46 103 48 43 93 74 46
X11 151 24 117 81 122 50 36 154 46 103 48 43 93 74 46
X12 151 24 117 81 122 50 36 154 46 103 48 43 93 74 46
X172 X173 X174 X175 X176 X177 X178 X179 X180 X181 X182 X183 X184 X185 X186
X2 53 84 81 124 88 125 57 167 106 124 125 50 126 97 60
X3 53 84 81 124 88 125 57 167 106 124 125 50 126 97 60
X4 53 84 81 124 88 125 57 167 106 124 125 50 126 97 60
X11 53 84 81 124 88 125 57 167 106 124 125 50 126 97 60
X12 53 84 81 124 88 125 57 167 106 124 125 50 126 97 60
X187 X188 X189 X190 X191 X192 X193 X194 X195 X196 X197 X198 X199 X200
X2 24 47 115 117 118 56 111 120 82 164 124 78 141 74
X3 24 47 115 117 118 56 111 120 82 164 124 78 141 74
X4 24 47 115 117 118 56 111 120 82 164 124 78 141 74
X11 24 47 115 117 118 56 111 120 82 164 124 78 141 74
X12 24 47 115 117 118 56 111 120 82 164 124 78 141 74
45 more rows ...
$samples
group lib.size norm.factors
X1 1 4000 1.3667917
X2 1 7600 1.9821343
X3 1 6500 0.2451696
X4 1 12900 0.5690732
X5 1 10600 0.3700974
195 more rows ...
> convertTo(X, type="DESeq2")
converting counts to integer mode
class: DESeqDataSet
dim: 50 200
metadata(1): version
assays(1): counts
rownames(50): X2 X3 ... X97 X98
rowData names(0):
colnames(200): X1 X2 ... X199 X200
colData names(1): sizeFactor
> convertTo(X, type="monocle")
No methods found in "BiocGenerics" for requests: as.vector, unlist
CellDataSet (storageMode: environment)
assayData: 50 features, 200 samples
element names: exprs
protocolData: none
phenoData: none
featureData
featureNames: X2 X3 ... X98 (50 total)
fvarLabels: use_for_ordering
fvarMetadata: labelDescription
experimentData: use 'experimentData(object)'
Annotation:
>
>
>
>
>
> dev.off()
null device
1
>