CalcDEvsRest: Calculates one vs. all DE tests for sCVdata

CalcDEvsRestR Documentation

Calculates one vs. all DE tests for sCVdata

Description

Performs differential gene expression tests for each cluster in an sCVdata object, comparing the cells in the cluster to the remaining cells in the data using the gene expression matrix of input data object. Alternatively, this function can be skipped, and existing DE test results can be assigned directly to the sCVdata object.

Usage

CalcDEvsRest(sCVd, inD)

## S4 method for signature 'sCVdata'
CalcDEvsRest(sCVd, inD)

Arguments

sCVd

An sCVdata object.

inD

The input dataset. An object of class seurat or SingleCellExperiment. Other data classes are not currently supported. Please submit requests for other data objects here!

Details

This function performs Wilcoxon rank sum tests comparing gene expression between each cluster and all other cells in the input data. Gene expression ratio in log space (logGER) is reported for all genes in the comparison. Genes are tested if they are detected in the cluster at a higher proportion than Param(sCVd,"DRthresh"), and both unadjusted p-values and false discovery rates are reported for all genes tested. To help track its progress, this function uses progress bars from pbapply. To disable these, set pboptions(type="none"). To re-enable, set pboptions(type="timer").

If using existing DE test results, assign results of one vs. all tests for every cluster in sCVdata to the DEvsRest slot of the sCVdata object. See example and slot documentation.

Value

A named list of data frames, one entry for each level in Clusters(sCVd) (with corresponding name). Each entry is data frame containing gene differential expression stats when comparing the cells of that cluster to all other cells in the input data. Rows represent genes, and variables include logGER (an effect size measure: gene expression ratio in log space, often referred to as logFC) and FDR (significance measure: false discovery rate). Also included are Wstat and pVal, the test statistic and the p-value of the Wilcoxon rank sum test.

Methods (by class)

  • sCVdata: Calculate one vs. all DE tests for sCVdata

See Also

CalcSCV for wrapper function to calculate all statistics for an sCVdata object, and fx_calcESvsRest and fx_calcDEvsRest for the internal functions performing the calculations. Wilcox test is now powered by wilcoxauc for super speed.

Examples

## Not run: 
## Example using CalcDEvsRest ##
DEvsRest(your_sCV_obj) <- CalcDEvsRest(sCVd=your_sCV_obj,
                                       inD=your_scRNAseq_data_object)


## Example using MAST results from Seurat to replace CalcDEvsRest ##
MAST_oneVSall <- FindAllMarkers(your_seurat_obj,
                                logfc.threshold=0,
                                min.pct=0.1,
                                test.use="MAST",
                                latent.vars="nUMI")
# ^ FindAllMarkers and CalcDEvsRest do equivalent comparisons 

names(MAST_oneVSall)[names(MAST_oneVSall) == "avg_logFC"] <- "logGER"
# ^ Effect size variable must be named 'logGER'
names(MAST_oneVSall)[names(MAST_oneVSall) == "p_val_adj"] <- "FDR"
# ^ Significance variable must be named 'FDR'

MAST_oneVSall_list <- sapply(levels(MAST_oneVSall$cluster),
                             function(X) {
                               temp <- MAST_oneVSall[MAST_oneVSall$cluster == X,]
                               rownames(temp) <- temp$gene
                               # ^ Rownames must be gene names.
                               return(temp)
                             },simplify=F)
# ^ Dataframe converted to list of dataframes per cluster

DEvsRest(your_sCV_obj) <- MAST_oneVSall_list
# ^ Slot MAST results into sCVdata object


## End(Not run)


BaderLab/scClustViz documentation built on Sept. 10, 2023, 11:51 p.m.