MASC: MASC - Mixed effect modeling of Associations of Single Cells

Description Usage Arguments Value Examples

View source: R/masc.R

Description

MASC - Mixed effect modeling of Associations of Single Cells

Usage

1
MASC(data, cluster, contrast, random.effects, fixed.effects, verbose = TRUE)

Arguments

data

A data frame containing the contrast factor, random, and fixed effects for the model

cluster

A factor indicating cluster assignments for each cell

contrast

A vector indicating the factor to be used as a contrast term

random.effects

A vector indicating which terms should be modeled as random effects covariates

fixed.effects

A vector indicating wich terms should be modeled as fixed effects covariates

verbose

TRUE/FALSE

Value

data frame containing calculated association p-values and odds ratios for each cluster tested

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Create test dataset with three clusters of 100 cells each
test.df <- data.frame(cluster = factor(rep(c(1, 2, 3), each = 100)))
# Create 6 donors that are cases or controls and include covariates
donors.df <- data.frame(donor = rep(paste("Donor", LETTERS[1:6], sep = "_"), each = 50),
sex = rep(c("M", "F", "M", "F", "F", "M"), each = 50),
status = rep(c("Case", "Case", "Control", "Control", "Case", "Control"), each = 50))
# Now make cluster 1 mostly case, cluster 2 mostly controls, etc
cases <- donors.df[donors.df$status == "Case",]
cases <- cases[sample(nrow(cases)),]
controls <- donors.df[donors.df$status == "Control",]
controls <- controls[sample(nrow(controls)),]
test.df <- cbind(rbind(cases[1:75,], controls[1:25,], cases[76:115,], controls[26:85,], cases[116:150,], controls[86:150,]), test.df)
# Test set call
library(lme4)
MASC(data = test.df, cluster = test.df$cluster, contrast = "status", random.effects = "donor", fixed.effects = "sex")

immunogenomics/masc documentation built on April 17, 2021, 9:33 a.m.