Case 3: MNP cell

Datasource: Cross-tissue single-cell landscape of human monocytes and macrophages in health and disease.

This example data has been integrated in the SPARKLE (SPARKLE::MNP.metadata)

Input data

Input formats : Seurat metadata

library(SPARKLE)
metadata <-SPARKLE::MNP.metadata 

 
knitr::kable(head(metadata), caption = "Seurat metadata")  
Seurat metadata
orig.ident nCount_RNA nFeature_RNA Initial.No Study.No Ascites.1_Blood.2_Breast.3_Colon.4_Stomach.5_Kidney.6_Liver.7_Lung.8_Pancreas.9_Skin.10_Spleen.11_Tonsil.12 Patient.No MirgDC.1_DC1.2_DC2.3_MacroMono.4 Study Tissue Status Clusters.NO Clusters nCount_integrated nFeature_integrated
ACTTGTTCACCGCTAG.1_1 SeuratProject 1628.662 719 1 1 1 1 3 Tang-Huau Ascites Healthy 6 T cell doublets 337.7403 1387
ATTGGACCATGTCCTC.1_1 SeuratProject 1028.799 342 2 1 1 1 3 Tang-Huau Ascites Healthy 6 T cell doublets 262.4473 1390
CCTTACGTCCCTGACT.1_1 SeuratProject 1779.581 959 3 1 1 1 3 Tang-Huau Ascites Healthy 6 T cell doublets 332.5596 1415
TGTTCCGCAGAAGCAC.1_1 SeuratProject 1493.055 578 4 1 1 1 1 Tang-Huau Ascites Healthy 6 T cell doublets 350.6807 1364
TTGACTTGTACTCAAC.1_1 SeuratProject 1555.572 806 5 1 1 1 1 Tang-Huau Ascites Healthy 6 T cell doublets 320.1611 1435
AACTCAGGTAAGTGGC.2_1 SeuratProject 1460.183 767 6 1 1 1 3 Tang-Huau Ascites Healthy 6 T cell doublets 334.7708 1478
sparkle.data <- cwas_build_model_data(inputdata = metadata,Sample = "Patient.No",Phenotype = "Status",Celltype ="Clusters",Group ="Tissue",Subgroup = "Study.No",Control_label = "Healthy",Disease_label = "Cancer",selected_celltype = c("cDC1","mregDC","Macrophage-4"))
## [1] "Warning: No Covariate1 infomation"
## [1] "Warning: No Covariate2 infomation"
## [1] "No gene infomation added"
## [1] "No geneset score infomation added"

Data exporlation (Optional)

PCA

PCA plot for data exploration

cwas_pcadraw(sparkle.data) 

Wilcoxon

Wilcoxon rank sum test and plot

cwas_classic_comparision(sparkle.data)  

Hausman_test

Test for Group

df <- cwas_hausman_test_all(sparkle.data,variable = "Group")


knitr::kable(df, caption = "Hausman test")  
Hausman test
Celltype Hausman_Statistic Pvalue Model_Selection Varible
mregDC -1.0151489 1.0000000 Random Effects Model Group : Tissue
cDC1 0.2035418 0.9032365 Random Effects Model Group : Tissue
Macrophage_4 -0.0073076 1.0000000 Random Effects Model Group : Tissue

Test for Subgroup

df2 <- cwas_hausman_test_all(sparkle.data,variable = "Subgroup")

knitr::kable(df2, caption = "Hausman test") 
Hausman test
Celltype Hausman_Statistic Pvalue Model_Selection Varible
mregDC 15.003049 0.0005522 Fixed Effects Model Subgroup : Study.No
cDC1 6.989467 0.0303568 Fixed Effects Model Subgroup : Study.No
Macrophage_4 6.171417 0.0456976 Fixed Effects Model Subgroup : Study.No

Cell-phenotype association analysis

All model calculation

all.models <- cwas_allmodel_cal(sparkle.data)### calculation for all model

Heatmap plot for all model

p <- cwas_allmodel_heatmap(all.models)# Plot all model AIC and Pvalue

Forest plot for Best model selection

best.model <- cwas_autoselected_model(all.models)# Select the best model and plot

Cell-phenotype covariate analysis

all.model.cov <- cwas_2celltype_allmodel_cal(sparkle.data)# Select the best model and plot
cwas_allmodel_heatmap(all.model.cov)# Plot all model AIC and Pvalue

best.model.cov <- cwas_autoselected_model(all.model.cov)# Select the best model and plot

Cell-phenotype mediation analysis

Your_interested_celltype="mregDC"

all.model.med <- cwas_mediation_analysis(sparkle.data,X.cell = Your_interested_celltype,Best_model =best.model,method = "cell_mediate_cell" )# Select the best model and plot

Cell-phenotype moderation analysis

all.model.mod <- cwas_moderation_analysis(sparkle.data,X.cell =Your_interested_celltype,Best_model =best.model,method = "cell_moderation_cell" )# Select the best model and plot

Moderation network plot

# sparkle.data <-   cwas.test.data <-  cwas_build_model_data(inputdata = metadata,
#                                            Sample = "Sample", Phenotype = "Phenotype",
#                                            Celltype = "Celltype",Group = "Group",Subgroup = "Subgroup",
#                                            Control_label="Control",
#                                            Disease_label="Disease"
#                                            )



SPARKLE::Cell_phenotype_network_plot(sparkle.data )