treecor_ctprop: Pipeline for TreeCorTreat using celltype proportion as...

View source: R/treecor_ctprop.R

treecor_ctpropR Documentation

Pipeline for TreeCorTreat using celltype proportion as features

Description

Pipeline for TreeCorTreat using celltype proportion as features

Usage

treecor_ctprop(
  hierarchy_list,
  cell_meta,
  sample_meta,
  response_variable,
  method = "aggregate",
  formula = NULL,
  separate = T,
  analysis_type = "pearson",
  num_cancor_components = 1,
  num_permutations = 1000,
  alternative = "two.sided",
  num_PCs = 2,
  verbose = T
)

Arguments

hierarchy_list

A hierarchy list by running 'extract_hrchy_string()' or 'extract_hrchy_seurat()' function. Contains four elements: 'edges', 'layout', 'immediate_children' and 'leaves_info'.

cell_meta

A data frame for cell-level metadata, with cells on the row. 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 to be used in the analysis, such as covariates or outcomes of interest.

response_variable

A vector of response variables. Extract these columns from 'sample_meta'.

method

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

formula

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

separate

A TRUE (default) or FALSE indicator, specifying how to evaluate multivariate outcomes.

  • TRUE: evaluate multivariate phenotype separately (it is equivalent to run this pipeline for each univariate phenotype).

  • FALSE: evaluate multivariate phenotype jointly.

analysis_type

Specify a summary statistic for analysis, must be one of

  • pearson (default): Pearson correlation (only for method = 'aggregate')

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

  • cancor: Canonical correlation

  • regression: Fit a linear regression with cell type proportion feature vectors as dependent variable and phenotype(s) as explanatory variables (full model). Compare between full model (with phenotypes in explanatory variables) and reduced model (without phenotypes).

num_cancor_components

Number of canonical components to be extracted. Only works for multivariate phenotypes when specifying 'separate = F' and 'analysis_type = cancor'.

num_permutations

Number of permutations (by default: 1000).

alternative

A character string 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

Examples

# default setting
result <- treecor_ctprop(hierarchy_list, cell_meta, sample_meta, response_variable = 'severity')
# extract a table of summary statistic for each cell cluster
result[[1]] # or result$canonical_corr
# extract a list of PC matrices for each cell cluster
result[[2]] # or result$pc.ls
# extract PC matrix for celltype 'T'
result$pc.ls[['T']]

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