ctprop_cancor: Core function for running treecor_ctprop() pipeline.

View source: R/ctprop_cancor.R

ctprop_cancorR Documentation

Core function for running treecor_ctprop() pipeline.

Description

This function calculates celltype proportion for each sample, performs Principal Component Analysis (PCA), calculates correlation/summary statistic based on top K chosen PCs and obtains permutation based p-value.

Usage

ctprop_cancor(
  cell_meta,
  sample_meta,
  response_variable,
  method,
  formula = NULL,
  analysis_type = "pearson",
  leaves_info,
  immediate_children,
  component_id = 1,
  num_permutations = 100,
  alternative = "two.sided",
  num_PCs = 2,
  verbose = T
)

Arguments

cell_meta

A data frame for cell-level metadata, where each row is a cell. Must contain these columns: barcode, celltype and sample.

sample_meta

A data frame for sample-level metadata, where each row is a sample. Must contain 'sample' column and additional variables such as covariates or outcome of interest.

response_variable

A vector of response variables. Will be used to calculate canonical correlation.

method

A character string indicating which approach is used to summarize features. One of 'concat_leaf (default)' or 'concat_immediate_children' or 'aggregate'.

formula

An object of class 'formula': a symbolic description of the model to be fitted, adjusting for confounders.

analysis_type
  • pearson: Pearson correlation (default; only works when method = 'aggregate')

  • spearman: Spearman correlation (only works when method = 'aggregate')

  • cancor: Canonical correlation

  • regression: Regression framework

leaves_info

A data frame that encodes leaf children for each node. Can be extracted from 'hierarchy_list' by running 'extract_hrchy_string()' or 'extract_hrchy_seurat()' function

immediate_children

A data frame that contains immediate children for each node. Can be extracted from 'hierarchy_list' by running 'extract_hrchy_string()' or 'extract_hrchy_seurat()' function

component_id

An index to extract canonical correlation component (by default: 1).

num_permutations

Number of permutations (by default: 1000).

alternative

Specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

num_PCs

Number of PCs

verbose

Show progress

Value

A list of two elements: the first element is a table of summary statistic for each tree node and second element is a list of PC matrices for each tree node.

Author(s)

Boyang Zhang <bzhang34@jhu.edu>, Hongkai Ji


byzhang23/TreeCorTreat documentation built on May 7, 2024, 8:37 a.m.