This is the main function to access slot data data from a particular gene
(or a small set of genes) as a tidy table. If data for all genes
must be retrieved (as a large matrix), use the GetTable
function. For analysis results, use the GetAnalysisTable
function.
Usage
GetData(
data,
mode.slot = DefaultSlot(data),
columns = NULL,
genes = Genes(data),
by.rows = FALSE,
coldata = TRUE,
ntr.na = TRUE,
name.by = "Symbol"
)
Arguments
- data
A grandR object
- mode.slot
Which kind of data to access (see details)
- columns
A vector of columns (see details); all condition/cell names if NULL
- genes
Restrict the output table to the given genes (this typically is a single gene, or very few genes)
- by.rows
if TRUE, add rows if there are multiple genes / mode.slots; otherwise, additional columns are appended
- coldata
Should the table contain the Coldata values as well (at the beginning)?
- ntr.na
For columns representing a 4sU naive sample, should mode.slot ntr,new.count and old.count be 0,0 and count (ntr.na=FALSE; can be any other slot than count) or NA,NA and NA (ntr.na=TRUE)
- name.by
A column name of Coldata(data). This is used as the colnames of the output table
Details
To refer to data slots, the mode.slot syntax can be used: Each name is either a data slot, or one of (new,old,total) followed by a dot followed by a slot. For new or old, the data slot value is multiplied by ntr or 1-ntr. This can be used e.g. to obtain the new counts.
If only one mode.slot and one gene is given, the output table contains one column (and potentially columns from Coldata) named Value. If one gene and multiple mode.slots are given, the columns are named according to the mode.slots. If one mode.slot and multiple genes are given, the columns are named according to the genes. If multiple genes and mode.slots are given, columns are named gene.mode.slot.
If by.rows=TRUE, the table is molten such that each row contains only one value (for one of the genes and for one of the mode.slots). If only one gene and one mode.slot is given, melting does not have an effect.
Columns can be given as a logical, integer or character vector representing a selection of the columns (samples or cells).
The expression is evaluated in an environment havin the Coldata
, i.e. you can use names of Coldata
as variables to
conveniently build a logical vector (e.g., columns=Condition=="x").
Examples
sars <- ReadGRAND(system.file("extdata", "sars.tsv.gz", package = "grandR"),
design=c("Cell",Design$dur.4sU,Design$Replicate))
#> Warning: Duplicate gene symbols (n=1, e.g. MATR3) present, making unique!
GetData(sars,mode.slot="ntr",gene="MYC")
#> Name Cell Replicate duration.4sU duration.4sU.original
#> Mock.no4sU.A Mock.no4sU.A Mock A 0 no4sU
#> Mock.1h.A Mock.1h.A Mock A 1 1h
#> Mock.2h.A Mock.2h.A Mock A 2 2h
#> Mock.2h.B Mock.2h.B Mock B 2 2h
#> Mock.3h.A Mock.3h.A Mock A 3 3h
#> Mock.4h.A Mock.4h.A Mock A 4 4h
#> SARS.no4sU.A SARS.no4sU.A SARS A 0 no4sU
#> SARS.1h.A SARS.1h.A SARS A 1 1h
#> SARS.2h.A SARS.2h.A SARS A 2 2h
#> SARS.2h.B SARS.2h.B SARS B 2 2h
#> SARS.3h.A SARS.3h.A SARS A 3 3h
#> SARS.4h.A SARS.4h.A SARS A 4 4h
#> no4sU Value
#> Mock.no4sU.A TRUE NA
#> Mock.1h.A FALSE 0.6207
#> Mock.2h.A FALSE 1.0000
#> Mock.2h.B FALSE 1.0000
#> Mock.3h.A FALSE 1.0000
#> Mock.4h.A FALSE 1.0000
#> SARS.no4sU.A TRUE NA
#> SARS.1h.A FALSE 0.5725
#> SARS.2h.A FALSE 1.0000
#> SARS.2h.B FALSE 1.0000
#> SARS.3h.A FALSE 1.0000
#> SARS.4h.A FALSE 1.0000
# one gene, one mode.slot
GetData(sars,mode.slot=c("count","ntr"),gene="MYC",coldata = FALSE)
#> count ntr
#> Mock.no4sU.A 428 NA
#> Mock.1h.A 4768 0.6207
#> Mock.2h.A 6196 1.0000
#> Mock.2h.B 4422 1.0000
#> Mock.3h.A 8356 1.0000
#> Mock.4h.A 6723 1.0000
#> SARS.no4sU.A 274 NA
#> SARS.1h.A 1906 0.5725
#> SARS.2h.A 5009 1.0000
#> SARS.2h.B 4207 1.0000
#> SARS.3h.A 1893 1.0000
#> SARS.4h.A 2307 1.0000
# one gene, multiple mode.slots
GetData(sars,mode.slot=c("count","ntr"),gene=c("SRSF6","MYC"),by.rows=TRUE)
#> Name Cell Replicate duration.4sU duration.4sU.original no4sU Gene
#> 1 Mock.no4sU.A Mock A 0 no4sU TRUE SRSF6
#> 2 Mock.1h.A Mock A 1 1h FALSE SRSF6
#> 3 Mock.2h.A Mock A 2 2h FALSE SRSF6
#> 4 Mock.2h.B Mock B 2 2h FALSE SRSF6
#> 5 Mock.3h.A Mock A 3 3h FALSE SRSF6
#> 6 Mock.4h.A Mock A 4 4h FALSE SRSF6
#> 7 SARS.no4sU.A SARS A 0 no4sU TRUE SRSF6
#> 8 SARS.1h.A SARS A 1 1h FALSE SRSF6
#> 9 SARS.2h.A SARS A 2 2h FALSE SRSF6
#> 10 SARS.2h.B SARS B 2 2h FALSE SRSF6
#> 11 SARS.3h.A SARS A 3 3h FALSE SRSF6
#> 12 SARS.4h.A SARS A 4 4h FALSE SRSF6
#> 13 Mock.no4sU.A Mock A 0 no4sU TRUE MYC
#> 14 Mock.1h.A Mock A 1 1h FALSE MYC
#> 15 Mock.2h.A Mock A 2 2h FALSE MYC
#> 16 Mock.2h.B Mock B 2 2h FALSE MYC
#> 17 Mock.3h.A Mock A 3 3h FALSE MYC
#> 18 Mock.4h.A Mock A 4 4h FALSE MYC
#> 19 SARS.no4sU.A SARS A 0 no4sU TRUE MYC
#> 20 SARS.1h.A SARS A 1 1h FALSE MYC
#> 21 SARS.2h.A SARS A 2 2h FALSE MYC
#> 22 SARS.2h.B SARS B 2 2h FALSE MYC
#> 23 SARS.3h.A SARS A 3 3h FALSE MYC
#> 24 SARS.4h.A SARS A 4 4h FALSE MYC
#> 25 Mock.no4sU.A Mock A 0 no4sU TRUE SRSF6
#> 26 Mock.1h.A Mock A 1 1h FALSE SRSF6
#> 27 Mock.2h.A Mock A 2 2h FALSE SRSF6
#> 28 Mock.2h.B Mock B 2 2h FALSE SRSF6
#> 29 Mock.3h.A Mock A 3 3h FALSE SRSF6
#> 30 Mock.4h.A Mock A 4 4h FALSE SRSF6
#> 31 SARS.no4sU.A SARS A 0 no4sU TRUE SRSF6
#> 32 SARS.1h.A SARS A 1 1h FALSE SRSF6
#> 33 SARS.2h.A SARS A 2 2h FALSE SRSF6
#> 34 SARS.2h.B SARS B 2 2h FALSE SRSF6
#> 35 SARS.3h.A SARS A 3 3h FALSE SRSF6
#> 36 SARS.4h.A SARS A 4 4h FALSE SRSF6
#> 37 Mock.no4sU.A Mock A 0 no4sU TRUE MYC
#> 38 Mock.1h.A Mock A 1 1h FALSE MYC
#> 39 Mock.2h.A Mock A 2 2h FALSE MYC
#> 40 Mock.2h.B Mock B 2 2h FALSE MYC
#> 41 Mock.3h.A Mock A 3 3h FALSE MYC
#> 42 Mock.4h.A Mock A 4 4h FALSE MYC
#> 43 SARS.no4sU.A SARS A 0 no4sU TRUE MYC
#> 44 SARS.1h.A SARS A 1 1h FALSE MYC
#> 45 SARS.2h.A SARS A 2 2h FALSE MYC
#> 46 SARS.2h.B SARS B 2 2h FALSE MYC
#> 47 SARS.3h.A SARS A 3 3h FALSE MYC
#> 48 SARS.4h.A SARS A 4 4h FALSE MYC
#> mode.slot Value
#> 1 count 367.0000
#> 2 count 3607.0000
#> 3 count 2972.0000
#> 4 count 3272.0000
#> 5 count 4747.0000
#> 6 count 3799.0000
#> 7 count 189.0000
#> 8 count 1381.0000
#> 9 count 1729.0000
#> 10 count 2302.0000
#> 11 count 753.0000
#> 12 count 954.0000
#> 13 count 428.0000
#> 14 count 4768.0000
#> 15 count 6196.0000
#> 16 count 4422.0000
#> 17 count 8356.0000
#> 18 count 6723.0000
#> 19 count 274.0000
#> 20 count 1906.0000
#> 21 count 5009.0000
#> 22 count 4207.0000
#> 23 count 1893.0000
#> 24 count 2307.0000
#> 25 ntr NA
#> 26 ntr 0.2248
#> 27 ntr 0.4202
#> 28 ntr 0.4347
#> 29 ntr 0.5518
#> 30 ntr 0.7180
#> 31 ntr NA
#> 32 ntr 0.3467
#> 33 ntr 0.7785
#> 34 ntr 0.7489
#> 35 ntr 0.8609
#> 36 ntr 0.9360
#> 37 ntr NA
#> 38 ntr 0.6207
#> 39 ntr 1.0000
#> 40 ntr 1.0000
#> 41 ntr 1.0000
#> 42 ntr 1.0000
#> 43 ntr NA
#> 44 ntr 0.5725
#> 45 ntr 1.0000
#> 46 ntr 1.0000
#> 47 ntr 1.0000
#> 48 ntr 1.0000
# multiple genes, multiple mode.slots, by rows