create.sumtable - create a data.table 'summarising' cellular data by sample and population/cluster.
Source:R/create.sumtable.R
create.sumtable.Rd
This function summarises cellular data and generates a summary data.table
Arguments
- dat
NO DEFAULT. A data.table containing cells (rows) vs features/markers (columns). One column must represent sample names, and another must represent populations/clusters.
- sample.col
NO DEFAULT. Character. Name of the sample column (e.g. "Sample").
- pop.col
NO DEFAULT. Character. Name of the population/cluster column (e.g. "Population", "Cluster").
- use.cols
DEFAULT = NULL A character vector indicating the columns to be measured (e.g. cellular columns – c("CD45", "CD3e") etc).
- annot.cols
DEFAULT = NULL. A character vector indicating the columns to be included as annotation columns (e.g. c("Batch", "Group") etc).
- parent.col
DEFAULT = NULL. A character entry indicating a column that represents the 'lineage' each population belongs to (e.g. 'CD4 T cells' may belong to the 'T cells' lineage). Use this to also calculate each population as a percentage of lineage.
- counts
DEFAULT = NULL. If you wish to calculate the actual number of cells per sample, a data.frame or data.table containing the sample names (in column 1) and cell counts per sample (column 2).
- perc.pos
DEFAULT = NULL. If you wish to calculate the percentage of each population that is 'positive' for a marker, you can provide a data.table containing the mark names (in column 1) and cut off values for positivity (column 2).
- double.pos
DEDAULT = NULL. List of vectors, each vector containing the names of multiple markers you wish to calculate % positive for (e.g. CD38+HLADR+). Generates 'and' and 'or' combinations.
- func
DEFAULT = "median". Can be "median" or "mean". Defines the type of function for calculating MFI data.
- sep
DEFAULT = " – ". Character separation of the measurement type and the population (e.g. MFI of CD4 – T cells)
Author
Thomas M Ashhurst, thomas.ashhurst@sydney.edu.au
Examples
## Calculate and export results from demonstration data
dat <- Spectre::demo.clustered
counts <- data.frame('Sample' = unique(dat[['Sample']]),
'Counts' = c(rep(100000, 6), rep(1000000, 6)))
sum.dat <- create.sumtable(dat = dat,
sample.col = "Sample",
pop.col = "Population",
use.cols = names(dat)[c(11:19)],
counts = counts)
#> Loading required package: data.table
#> Creating sumtable
#> -- running some initial tests
#> -- calculting cell proportions
#> -- calculating cell counts
#> -- calculting expression levels
#> -- wrapping up
#> -- sumtable complete!