
Compare Cohorts
compareCohorts.Rd
Function to compare the proportions of categorical cell annotations (e.g. cell phenotypes,
neighborhood annotations) across cohorts of samples defined in the projectMetadata
of a SpatialMap object.
Usage
compareCohorts(
object,
feature,
cohort_colname,
sample_colname = "Region",
select_cohorts = NULL
)
Arguments
- object
A SpatialMap object
- feature
(character) The name of a cellMetadata column corresponding to cell-level labels that are being tested
- cohort_colname
(character) Column from projectMetadata that marks which samples belong to which cohort.
- sample_colname
(character) Column from projectMetadata that marks which Regions belong to which samples (defaults to Region i.e. each Region is a statistically independent sample). Useful when multiple images belong to the same sample.
- select_cohorts
(character) (optional) in case you want to specify which values from
cohort_colname
are being compared. Expects a two-element character vector. Can also be used to define which cohort is the "reference" (negative log fold change) and which is the "comparison" (positive log fold change). The "comparison" cohort should come first.
Value
A dataframe of statistical tests, with the following columns:
cluster
: The cluster (feature
) the hypothesis test was performed on.P.Value
&P.Value.method
: Nominal p-value and the test used to compute it. A two-sided T-test is performed, comparing the proportion of cells within each sample between the cohorts.adj.P.Val
&adj.P.Val.method
: Method of obtaining adjusted p-value (uses false discovery rate by default)logFC
: Log2 fold-change between cohorts. Formula: \(log2(P_1/P_2)\), where \(P_1\) and \(P_2\) are the respective proportions of that cluster in each cohort. Ifselect_cohorts
was used, \(P_1\) is from the first cohort specified there (the "comparsion" cohort).count
: Number of total cells among all cohorts.count_*
: Number of total cells among each sample cohort. The "comparison" cohort will come first in the columns.mean_proportion
: Mean of the proportions across all cohorts.`mean_proportion_*``Mean of the proportion among each sample cohort. The "comparison" cohort will come first in the columns.
Details
See vignette("AnalysisGuide7_Cohort_comparison")
for an example workflow that makes use of this function.