Skip to contents

This function is designed to compare the pairwise adjacency distributions of two groups of Regions.

It takes a SpatialMap, and two groups of Regions, and returns a list of data frames. Instead of explicit Region groupings, it can also take a contrast from projectMetadata (a metadata column). Note that the function assumes that all Regions have had pairwiseAdjacency run on the same set of NN graphs, and that the NN adjacency graphs for each Region were all computed in the same way. If pairwiseAdjacency was used to perform sample level analysis, all regions for each sample must belong to either group1 or group2.

Usage

compareAdjacency(
  object,
  feature,
  nn,
  group.1,
  group.2 = NULL,
  comparison.method = "fisher.test",
  adjustment_method = "BH"
)

Arguments

object

A SpatialMap object

feature

The name of a cellMetadata column (character).

nn

The name of a nearestNeighborGraph from object (character).

group.1

Vector of Region names, or a column name in projectMetadata used for grouping. If a projectMetadata column name is passed, group.2 should be NULL. In this case, for each categorical level in the given column, two cohorts are defined:

  1. All regions matching that categorical level in the specified projectMetadata column

  2. All regions not matching that level

group.2

Vector of Region names. If NULL, looks in projectMetadata for a column name matching group.1 to create cohorts.

comparison.method

Warning: this parameter doesn't do anything yet. will be used as background relative to group.1

adjustment_method

Method for calculating multiple hypothesis corrections. Passed to stats::p.adjust(). Applied for both odds ratio and interaction proportion calculations.

Value

A named list of 4 data.frames:

grouped_adjacency_results

Raw interaction counts per sample, and the sample-level statistics for each interaction previously computed by pairwiseAdjacency.

cohort_interaction_summary

Aggregated interaction counts in cohort 1 and cohort 2 with a Fisher's Test result.

log_odds_t_test

A t-test between the log2-transformed interaction odds ratios (i.e. log2-enrichment scores relative to analytic or permuted null background, from each sample's pairwiseAdjacency calculation).

logit_proportions_t_test

A t-test on logit-transformed interaction proportions for each sample (i.e. the proportion of interactions of that type relative to all interactions in that sample).

If a projectMetadata column was passed to group.1, the output will be a named list of lists (names correspond to the level used to define "group.1" for that iteration).

Details

See vignette("AnalysisGuide7_Cohort_comparison") for a representative workflow that uses this function.

Scroll to top