Last updated: 2022-09-20

Checks: 7 0

Knit directory: GSFA_analysis/

This reproducible R Markdown analysis was created with workflowr (version 1.7.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20220524) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 3ee8219. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .DS_Store
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/

Untracked files:
    Untracked:  Rplots.pdf
    Untracked:  analysis/check_Tcells_datasets.Rmd
    Untracked:  analysis/fscLVM_analysis.Rmd
    Untracked:  analysis/spca_LUHMES_data.Rmd
    Untracked:  analysis/test_seurat.Rmd
    Untracked:  code/gsfa_negctrl_job.sbatch
    Untracked:  code/music_LUHMES_Yifan.R
    Untracked:  code/plotting_functions.R
    Untracked:  code/run_fscLVM_LUHMES_data.R
    Untracked:  code/run_gsfa_2groups_negctrl.R
    Untracked:  code/run_gsfa_negctrl.R
    Untracked:  code/run_music_LUHMES.R
    Untracked:  code/run_music_LUHMES_data.sbatch
    Untracked:  code/run_music_LUHMES_data_20topics.R
    Untracked:  code/run_music_LUHMES_data_20topics.sbatch
    Untracked:  code/run_sceptre_Tcells_data.sbatch
    Untracked:  code/run_sceptre_Tcells_stimulated_data.sbatch
    Untracked:  code/run_sceptre_Tcells_test_data.sbatch
    Untracked:  code/run_sceptre_Tcells_unstimulated_data.sbatch
    Untracked:  code/run_sceptre_permuted_data.sbatch
    Untracked:  code/run_spca_LUHMES.R
    Untracked:  code/run_spca_TCells.R
    Untracked:  code/run_twostep_clustering_LUHMES_data.sbatch
    Untracked:  code/run_twostep_clustering_Tcells_data.sbatch
    Untracked:  code/run_unguided_gsfa_LUHMES.R
    Untracked:  code/run_unguided_gsfa_LUHMES.sbatch
    Untracked:  code/run_unguided_gsfa_Tcells.R
    Untracked:  code/run_unguided_gsfa_Tcells.sbatch
    Untracked:  code/sceptre_LUHMES_data.R
    Untracked:  code/sceptre_Tcells_stimulated_data.R
    Untracked:  code/sceptre_Tcells_unstimulated_data.R
    Untracked:  code/sceptre_permutation_analysis.R
    Untracked:  code/sceptre_permute_analysis.R
    Untracked:  code/seurat_sim_fpr_tpr.R
    Untracked:  code/unguided_GFSA_mixture_normal_prior.cpp

Unstaged changes:
    Modified:   analysis/sceptre_TCells_data.Rmd
    Modified:   analysis/twostep_clustering_LUHMES_data.Rmd
    Modified:   code/run_sceptre_LUHMES_data.R
    Modified:   code/run_sceptre_LUHMES_data.sbatch
    Modified:   code/run_sceptre_LUHMES_permuted_data.R
    Modified:   code/run_sceptre_Tcells_permuted_data.R
    Modified:   code/run_sceptre_cropseq_data.sbatch
    Modified:   code/run_twostep_clustering_LUHMES_data.R
    Modified:   code/sceptre_analysis.R

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/twostep_clustering_TCells_data.Rmd) and HTML (docs/twostep_clustering_TCells_data.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 3ee8219 kevinlkx 2022-09-20 updated the size of qq plots
html 1080c0f kevinlkx 2022-09-20 Build site.
html 9a47c79 kevinlkx 2022-09-08 Build site.
Rmd 8bcdaac kevinlkx 2022-09-08 updated the Seurat results
html 748aea1 kevinlkx 2022-08-31 Build site.
Rmd 2d2298a kevinlkx 2022-08-31 added qqplots for combined results
html 104e391 kevinlkx 2022-08-25 Build site.
Rmd a27762b kevinlkx 2022-08-25 added qqplots
html 16d9226 kevinlkx 2022-08-12 Build site.
Rmd 717bb32 kevinlkx 2022-08-12 added more descriptions
html d51d6c4 kevinlkx 2022-08-12 Build site.
Rmd 9c06976 kevinlkx 2022-08-12 added more descriptions
html ee884c4 kevinlkx 2022-08-11 Build site.
Rmd ce094cd kevinlkx 2022-08-11 update intro formating and barplot for DEGs

mkdir -p /project2/xinhe/kevinluo/GSFA/data

cp /project2/xinhe/yifan/Factor_analysis/shared_data/TCells_cropseq_data_seurat.rds \
  /project2/xinhe/kevinluo/GSFA/data

cp /project2/xinhe/yifan/Factor_analysis/Stimulated_T_Cells/GSE119450_RAW/D1N/genes.tsv \
  /project2/xinhe/kevinluo/GSFA/data/Stimulated_T_Cells_GSE119450_RAW_D1N_genes.tsv.gz

Scripts for running the analysis:

mkdir -p /project2/xinhe/kevinluo/GSFA/twostep_clustering/log
cd /project2/xinhe/kevinluo/GSFA/twostep_clustering/log

sbatch --mem=40G ~/projects/GSFA_analysis/code/run_twostep_clustering_Tcells_data.sbatch

Load the data sets

CROP-seq datasets: /project2/xinhe/yifan/Factor_analysis/shared_data/LUHMES_cropseq_data_seurat.rds The data are Seurat objects, with raw gene counts stored in obj@assays$RNA@counts, and cell meta data stored in obj@meta.data. Normalized and scaled data used for GSFA are stored in obj@assays$RNA@scale.data, the rownames of which are the 6k genes used for GSFA.

Load packages

dyn.load('/software/geos-3.7.0-el7-x86_64/lib64/libgeos_c.so') # attach the geos lib for Seurat
suppressPackageStartupMessages(library(data.table))
suppressPackageStartupMessages(library(Seurat))
suppressPackageStartupMessages(library(ComplexHeatmap))
suppressPackageStartupMessages(library(ggplot2))
require(reshape2)
require(dplyr)
require(ComplexHeatmap)
theme_set(theme_bw() + theme(plot.title = element_text(size = 14, hjust = 0.5),
                             axis.title = element_text(size = 14),
                             axis.text = element_text(size = 13),
                             legend.title = element_text(size = 13),
                             legend.text = element_text(size = 12),
                             panel.grid.minor = element_blank())
)

library(gridExtra)
source("code/plotting_functions.R")

Set directories

data_dir <- "/project2/xinhe/kevinluo/GSFA/data/"
res_dir <- "/project2/xinhe/kevinluo/GSFA/twostep_clustering/Stimulated_T_Cells/stimulated/"
# dir.create(res_dir, recursive = TRUE, showWarnings = FALSE)

Load two-step clustering analysis result

combined_obj <- readRDS(file.path(res_dir, "TCells_stimulated_seurat_clustered.rds"))

Associate perturbations with clusters

perturb_matrix <- combined_obj@meta.data[, 4:24]

cluster_labels <- Idents(combined_obj)
cluster_labels <- as.factor(as.numeric(as.character(cluster_labels))+1)
new_cluster_labels <- paste0("k", levels(cluster_labels))
names(new_cluster_labels) <- levels(combined_obj)
combined_obj <- RenameIdents(combined_obj, new_cluster_labels)

cluster_matrix <- matrix(0, nrow = nrow(perturb_matrix), ncol = length(levels(cluster_labels)))
cluster_matrix[cbind(1:nrow(perturb_matrix), cluster_labels)] <- 1
rownames(cluster_matrix) <- rownames(perturb_matrix)
colnames(cluster_matrix) <- new_cluster_labels

Use Chi-squared tests for the association of perturbations and clusters (2 x 2 tables)

summary_df <- expand.grid(colnames(perturb_matrix), colnames(cluster_matrix))
colnames(summary_df) <- c("perturb", "cluster")

summary_df <- cbind(summary_df, statistic = NA, stdres = NA, pval = NA)

for(i in 1:nrow(summary_df)){
  dt <- table(data.frame(perturb = perturb_matrix[,summary_df$perturb[i]], 
                         cluster = cluster_matrix[,summary_df$cluster[i]]))
  chisq <- chisq.test(dt)
  summary_df[i, ]$statistic <- chisq$statistic
  summary_df[i, ]$stdres <- chisq$stdres[2,2]
  summary_df[i, ]$pval <- chisq$p.value
}

summary_df$fdr <- p.adjust(summary_df$pval, method = "BH")
summary_df$bonferroni_adj <- p.adjust(summary_df$pval, method = "bonferroni")
# saveRDS(summary_df, file = file.path(res_dir, "TCells_stimulated_seurat_guide_cluster_chisq_summary_df.rds"))

stdres_mat <- reshape2::dcast(summary_df %>% dplyr::select(perturb, cluster, stdres), perturb ~ cluster, value.var = "stdres")
rownames(stdres_mat) <- stdres_mat$perturb
stdres_mat$perturb <- NULL

fdr_mat <- reshape2::dcast(summary_df %>% dplyr::select(perturb, cluster, fdr), perturb ~ cluster, value.var = "fdr")
rownames(fdr_mat) <- fdr_mat$perturb
fdr_mat$perturb <- NULL

bonferroni_mat <- reshape2::dcast(summary_df %>% dplyr::select(perturb, cluster, bonferroni_adj), 
                                  perturb ~ cluster, value.var = "bonferroni_adj")
rownames(bonferroni_mat) <- bonferroni_mat$perturb
bonferroni_mat$perturb <- NULL

Plot perturbation ~ cluster associations (show FDR)

KO_names <- rownames(fdr_mat)
dotplot_effectsize(t(stdres_mat), t(fdr_mat),
                   reorder_markers = c(KO_names[KO_names!="NonTarget"], "NonTarget"),
                   color_lgd_title = "Chi-squared test\nstandardized residuals",
                   size_lgd_title = "FDR",
                   max_score = 4,
                   min_score = -4,
                   by_score = 2) + coord_flip()

Version Author Date
9a47c79 kevinlkx 2022-09-08
ee884c4 kevinlkx 2022-08-11

Plot perturbation ~ cluster associations (show Bonferroni adjusted p-values)

KO_names <- rownames(bonferroni_mat)
dotplot_effectsize(t(stdres_mat), t(bonferroni_mat),
                   reorder_markers = c(KO_names[KO_names!="NonTarget"], "NonTarget"),
                   color_lgd_title = "Chi-squared test\nstandardized residuals",
                   size_lgd_title = "Bonferroni\nadjusted p-value",
                   max_score = 4,
                   min_score = -4,
                   by_score = 2) + coord_flip()

Version Author Date
9a47c79 kevinlkx 2022-09-08
ee884c4 kevinlkx 2022-08-11

Find DE genes for each cluster and assign DE genes to associated perturbations

First, find DE genes for each cluster using MAST (Bonferroni adjusted p-values < 0.05), Then, for each perturbation, find the associated clusters, and pull the DE genes for those clusters.

feature.names <- data.frame(fread(file.path(data_dir, "Stimulated_T_Cells_GSE119450_RAW_D1N_genes.tsv.gz"),
                                  header = FALSE), stringsAsFactors = FALSE)

de.markers <- readRDS(file.path(res_dir, "TCells_stimulated_seurat_MAST_DEGs.rds"))
names(de.markers) <- paste0("k", levels(cluster_labels))

de.genes.clusters <- vector("list", length = length(de.markers))
names(de.genes.clusters) <- names(de.markers)
for( i in 1:length(de.genes.clusters)){
  de_sumstats <- de.markers[[i]]
  de_genes <- unique(rownames(de_sumstats[de_sumstats$p_val_adj < 0.05,]))
  # de_genes <- feature.names$V2[match(de_genes, feature.names$V1)]
  de.genes.clusters[[i]] <- de_genes
}

Number of DE genes for each perturbation (Chi-squared test FDR < 0.05)

perturb_names <- rownames(fdr_mat)
perturb_names <- c("NonTarget", perturb_names[perturb_names!="NonTarget"])

de.genes.perturbs <- vector("list", length = length(perturb_names))
names(de.genes.perturbs) <- perturb_names

for(i in 1:length(de.genes.perturbs)){
  perturb_name <- names(de.genes.perturbs)[i]
  associated_cluster_labels <- colnames(fdr_mat)[which(fdr_mat[perturb_name, ] < 0.05)]
  if(length(associated_cluster_labels) > 0){
    de.genes.perturbs[[i]] <- unique(unlist(de.genes.clusters[associated_cluster_labels]))
  }
}

num.de.genes.perturbs <- sapply(de.genes.perturbs, length)
twostep_clustering_fdr0.05_genes <- de.genes.perturbs

dge_plot_df <- data.frame(Perturbation = names(num.de.genes.perturbs), Num_DEGs = num.de.genes.perturbs)
dge_plot_df$Perturbation <- factor(dge_plot_df$Perturbation, levels = names(num.de.genes.perturbs))

ggplot(data=dge_plot_df, aes(x = Perturbation, y = Num_DEGs+1)) +
  geom_bar(position = "dodge", stat = "identity") +
  geom_text(aes(label = Num_DEGs), position=position_dodge(width=0.9), vjust=-0.25) +
  scale_y_log10() +
  scale_fill_brewer(palette = "Set2") +
  labs(x = "Target gene",
       y = "Number of DEGs",
       title = "Number of DEGs detected by Two-step clustering with MAST DE analysis") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1, size = 12),
        legend.position = "bottom",
        legend.text = element_text(size = 13))

Version Author Date
9a47c79 kevinlkx 2022-09-08
ee884c4 kevinlkx 2022-08-11

Number of DE genes for each perturbation (Chi-squared test Bonferroni adjusted p-value < 0.05)

perturb_names <- rownames(bonferroni_mat)
perturb_names <- c("NonTarget", perturb_names[perturb_names!="NonTarget"])

de.genes.perturbs <- vector("list", length = length(perturb_names))
names(de.genes.perturbs) <- perturb_names

for(i in 1:length(de.genes.perturbs)){
  perturb_name <- names(de.genes.perturbs)[i]
  associated_cluster_labels <- colnames(bonferroni_mat)[which(bonferroni_mat[perturb_name, ] < 0.05)]
  if(length(associated_cluster_labels) > 0){
    de.genes.perturbs[[i]] <- unique(unlist(de.genes.clusters[associated_cluster_labels]))
  }
}

num.de.genes.perturbs <- sapply(de.genes.perturbs, length)
twostep_clustering_bonferroni0.05_genes <- de.genes.perturbs

dge_plot_df <- data.frame(Perturbation = names(num.de.genes.perturbs), Num_DEGs = num.de.genes.perturbs)
dge_plot_df$Perturbation <- factor(dge_plot_df$Perturbation, levels = names(num.de.genes.perturbs))

ggplot(data=dge_plot_df, aes(x = Perturbation, y = Num_DEGs+1)) +
  geom_bar(position = "dodge", stat = "identity") +
  geom_text(aes(label = Num_DEGs), position=position_dodge(width=0.9), vjust=-0.25) +
  scale_y_log10() +
  scale_fill_brewer(palette = "Set2") +
  labs(x = "Target gene",
       y = "Number of DEGs",
       title = "Number of DEGs detected by Two-step clustering with MAST DE analysis") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1, size = 12),
        legend.position = "bottom",
        legend.text = element_text(size = 13))

Version Author Date
9a47c79 kevinlkx 2022-09-08
ee884c4 kevinlkx 2022-08-11

Compare single-gene DE p-value distributions between two-step clustering analysis and GSFA

fdr_cutoff <- 0.05
lfsr_cutoff <- 0.05

Load the output of GSFA fit_gsfa_multivar() run.

data_folder <- "/project2/xinhe/yifan/Factor_analysis/Stimulated_T_Cells/"
fit <- readRDS(paste0(data_folder,
                      "gsfa_output_detect_01/all_uncorrected_by_group.use_negctrl/All.gibbs_obj_k20.svd_negctrl.restart.light.rds"))
gibbs_PM <- fit$posterior_means
lfsr_mat1 <- fit$lfsr1[, -ncol(fit$lfsr1)]
lfsr_mat0 <- fit$lfsr0[, -ncol(fit$lfsr0)]
total_effect1 <- fit$total_effect1[, -ncol(fit$total_effect1)]
total_effect0 <- fit$total_effect0[, -ncol(fit$total_effect0)]
KO_names <- colnames(lfsr_mat1)

DEGs detected by GSFA

   ARID1A      BTLA  C10orf54      CBLB      CD3D       CD5    CDKN1B      DGKA 
      393       107        66       631         0       645       468        32 
     DGKZ    HAVCR2      LAG3      LCP2     MEF2D NonTarget     PDCD1     RASA2 
      113        35         1       589        15         0         0       277 
    SOCS1     STAT6     TCEB2   TMEM222   TNFRSF9 
      356         1       300         4        14 

Load MAST single-gene DE result

guides <- KO_names[KO_names!="NonTarget"]

mast_list <- list()
for (m in guides){
  fname <- paste0(data_folder, "processed_data/MAST/all_by_stim_negctrl/gRNA_", 
                  m, ".dev_res_top6k.vs_negctrl.rds")
  tmp_df <- readRDS(fname)
  tmp_df$geneID <- rownames(tmp_df)
  tmp_df <- tmp_df %>% dplyr::rename(FDR = fdr, PValue = pval)
  mast_list[[m]] <- tmp_df
}
mast_signif_counts <- sapply(mast_list, function(x){filter(x, FDR < fdr_cutoff) %>% nrow()})

QQ-plots of MAST DE p-values for the GSFA significant genes vs two-step clustering DE genes.

qqplots <- list()
for(i in 1:length(guides)){
  guide <- guides[i]
  mast_res <- mast_list[[guide]]
  tsc_de_genes <- twostep_clustering_fdr0.05_genes[[guide]]
  gsfa_de_genes <- gsfa_sig_genes[[guide]]
  tsc_de_genes <- intersect(tsc_de_genes, rownames(mast_res))
  gsfa_de_genes <- intersect(gsfa_de_genes, rownames(mast_res))
  
  if(length(tsc_de_genes)>0 && length(gsfa_de_genes) >0){
    mast_res$tsc_gene <- 0
    mast_res[tsc_de_genes, ]$tsc_gene <- 1
    mast_res$gsfa_gene <- 0
    mast_res[gsfa_de_genes, ]$gsfa_gene <- 1
    pvalue_list <- list('Two-step clustering'=dplyr::filter(mast_res,tsc_gene==1)$PValue,
                        'GSFA'=dplyr::filter(mast_res,gsfa_gene==1)$PValue,
                        'all genes'=mast_res$PValue)
    qqplots[[guide]] <- qqplot.pvalue(pvalue_list, pointSize = 1, legendSize = 4) + 
      ggtitle(guide) + theme(plot.title = element_text(hjust = 0.5)) +
      scale_colour_discrete(name="Method")
  }
}

grid.arrange(grobs = qqplots, nrow = 3, ncol = 2)

Version Author Date
9a47c79 kevinlkx 2022-09-08
748aea1 kevinlkx 2022-08-31
104e391 kevinlkx 2022-08-25

Pooling p-values from all perturbations

combined_mast_res <- data.frame()
for(i in 1:length(guides)){
  guide <- guides[i]
  mast_res <- mast_list[[guide]]
  tsc_de_genes <- twostep_clustering_fdr0.05_genes[[guide]]
  gsfa_de_genes <- gsfa_sig_genes[[guide]]
  tsc_de_genes <- intersect(tsc_de_genes, rownames(mast_res))
  gsfa_de_genes <- intersect(gsfa_de_genes, rownames(mast_res))
  mast_res$tsc_gene <- 0
  if(length(tsc_de_genes) >0){
    mast_res[tsc_de_genes, ]$tsc_gene <- 1
  }
  mast_res$gsfa_gene <- 0
  if(length(gsfa_de_genes) >0){
    mast_res[gsfa_de_genes, ]$gsfa_gene <- 1
  }
  combined_mast_res <- rbind(combined_mast_res, mast_res)
}

pvalue_list <- list('Two-step clustering'=dplyr::filter(combined_mast_res,tsc_gene==1)$PValue,
                    'GSFA'=dplyr::filter(combined_mast_res,gsfa_gene==1)$PValue,
                    'all genes'=combined_mast_res$PValue)

qqplot.pvalue(pvalue_list, pointSize = 1, legendSize = 4) + 
      ggtitle("") + theme(plot.title = element_text(hjust = 0.5)) +
      scale_colour_discrete(name="Method")

Version Author Date
9a47c79 kevinlkx 2022-09-08
748aea1 kevinlkx 2022-08-31

QQ-plots of MAST DE p-values for the GSFA only genes vs two-step only genes.

qqplots <- list()
for(i in 1:length(guides)){
  guide <- guides[i]
  mast_res <- mast_list[[guide]]
  tsc_de_genes <- twostep_clustering_fdr0.05_genes[[guide]]
  gsfa_de_genes <- gsfa_sig_genes[[guide]]
  tsc_de_genes <- intersect(tsc_de_genes, rownames(mast_res))
  gsfa_de_genes <- intersect(gsfa_de_genes, rownames(mast_res))
  
  if(length(tsc_de_genes)>0 && length(gsfa_de_genes) >0){
    mast_res$tsc_only_gene <- 0
    mast_res[setdiff(tsc_de_genes, gsfa_de_genes), ]$tsc_only_gene <- 1
    mast_res$gsfa_only_gene <- 0
    mast_res[setdiff(gsfa_de_genes, tsc_de_genes), ]$gsfa_only_gene <- 1
    
    pvalue_list <- list('Two-step clustering only'=dplyr::filter(mast_res,tsc_only_gene==1)$PValue,
                        'GSFA only'=dplyr::filter(mast_res,gsfa_only_gene==1)$PValue,
                        'all genes'=mast_res$PValue)
    qqplots[[guide]] <- qqplot.pvalue(pvalue_list, pointSize = 1, legendSize = 4) + 
      ggtitle(guide) + theme(plot.title = element_text(hjust = 0.5)) +
      scale_colour_discrete(name="Method")
  }
}

grid.arrange(grobs = qqplots, nrow = 3, ncol = 2)

Version Author Date
9a47c79 kevinlkx 2022-09-08
748aea1 kevinlkx 2022-08-31
104e391 kevinlkx 2022-08-25

Pooling p-values from all perturbations

combined_mast_res <- data.frame()
for(i in 1:length(guides)){
  guide <- guides[i]
  mast_res <- mast_list[[guide]]
  tsc_de_genes <- twostep_clustering_fdr0.05_genes[[guide]]
  gsfa_de_genes <- gsfa_sig_genes[[guide]]
  tsc_de_genes <- intersect(tsc_de_genes, rownames(mast_res))
  gsfa_de_genes <- intersect(gsfa_de_genes, rownames(mast_res))
  mast_res$tsc_only_gene <- 0
  if(length(setdiff(tsc_de_genes, gsfa_de_genes)) >0){
    mast_res[setdiff(tsc_de_genes, gsfa_de_genes), ]$tsc_only_gene <- 1
  }
  mast_res$gsfa_only_gene <- 0
  if(length(setdiff(gsfa_de_genes, tsc_de_genes)) >0){
    mast_res[setdiff(gsfa_de_genes, tsc_de_genes), ]$gsfa_only_gene <- 1
  }
  combined_mast_res <- rbind(combined_mast_res, mast_res)
}

pvalue_list <- list('Two-step clustering only'=dplyr::filter(combined_mast_res,tsc_only_gene==1)$PValue,
                    'GSFA only'=dplyr::filter(combined_mast_res,gsfa_only_gene==1)$PValue,
                    'all genes'=combined_mast_res$PValue)

qqplot.pvalue(pvalue_list, pointSize = 1, legendSize = 4) + 
      ggtitle("") + theme(plot.title = element_text(hjust = 0.5)) +
      scale_colour_discrete(name="Method")

Version Author Date
9a47c79 kevinlkx 2022-09-08
748aea1 kevinlkx 2022-08-31

sessionInfo()
R version 4.2.0 (2022-04-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /software/openblas-0.3.13-el7-x86_64/lib/libopenblas_haswellp-r0.3.13.so

locale:
 [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C         LC_TIME=C           
 [4] LC_COLLATE=C         LC_MONETARY=C        LC_MESSAGES=C       
 [7] LC_PAPER=C           LC_NAME=C            LC_ADDRESS=C        
[10] LC_TELEPHONE=C       LC_MEASUREMENT=C     LC_IDENTIFICATION=C 

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
 [1] lattice_0.20-45       gridExtra_2.3         dplyr_1.0.9          
 [4] reshape2_1.4.4        ggplot2_3.3.6         ComplexHeatmap_2.12.0
 [7] sp_1.4-7              SeuratObject_4.1.0    Seurat_4.1.1         
[10] data.table_1.14.2     workflowr_1.7.0      

loaded via a namespace (and not attached):
  [1] circlize_0.4.15       plyr_1.8.7            igraph_1.3.4         
  [4] lazyeval_0.2.2        splines_4.2.0         listenv_0.8.0        
  [7] scattermore_0.8       digest_0.6.29         foreach_1.5.2        
 [10] htmltools_0.5.2       fansi_1.0.3           magrittr_2.0.3       
 [13] tensor_1.5            cluster_2.1.3         doParallel_1.0.17    
 [16] ROCR_1.0-11           globals_0.15.0        matrixStats_0.62.0   
 [19] R.utils_2.11.0        spatstat.sparse_2.1-1 colorspace_2.0-3     
 [22] ggrepel_0.9.1         xfun_0.30             callr_3.7.0          
 [25] crayon_1.5.1          jsonlite_1.8.0        progressr_0.10.0     
 [28] spatstat.data_2.2-0   survival_3.3-1        zoo_1.8-10           
 [31] iterators_1.0.14      glue_1.6.2            polyclip_1.10-0      
 [34] gtable_0.3.0          leiden_0.4.2          GetoptLong_1.0.5     
 [37] shape_1.4.6           future.apply_1.9.0    BiocGenerics_0.42.0  
 [40] abind_1.4-5           scales_1.2.0          DBI_1.1.3            
 [43] spatstat.random_2.2-0 miniUI_0.1.1.1        Rcpp_1.0.8.3         
 [46] viridisLite_0.4.0     xtable_1.8-4          clue_0.3-61          
 [49] reticulate_1.24       spatstat.core_2.4-2   stats4_4.2.0         
 [52] htmlwidgets_1.5.4     httr_1.4.3            RColorBrewer_1.1-3   
 [55] ellipsis_0.3.2        ica_1.0-2             R.methodsS3_1.8.1    
 [58] farver_2.1.0          pkgconfig_2.0.3       sass_0.4.1           
 [61] uwot_0.1.11           deldir_1.0-6          utf8_1.2.2           
 [64] labeling_0.4.2        tidyselect_1.1.2      rlang_1.0.2          
 [67] later_1.3.0           munsell_0.5.0         tools_4.2.0          
 [70] cli_3.3.0             generics_0.1.2        ggridges_0.5.3       
 [73] evaluate_0.15         stringr_1.4.0         fastmap_1.1.0        
 [76] yaml_2.3.5            goftest_1.2-3         processx_3.5.3       
 [79] knitr_1.39            fs_1.5.2              fitdistrplus_1.1-8   
 [82] purrr_0.3.4           RANN_2.6.1            pbapply_1.5-0        
 [85] future_1.25.0         nlme_3.1-157          whisker_0.4          
 [88] mime_0.12             R.oo_1.24.0           compiler_4.2.0       
 [91] rstudioapi_0.13       plotly_4.10.0         png_0.1-7            
 [94] spatstat.utils_2.3-1  tibble_3.1.7          bslib_0.3.1          
 [97] stringi_1.7.6         highr_0.9             ps_1.7.0             
[100] rgeos_0.5-9           Matrix_1.4-1          vctrs_0.4.1          
[103] pillar_1.7.0          lifecycle_1.0.1       spatstat.geom_2.4-0  
[106] lmtest_0.9-40         jquerylib_0.1.4       GlobalOptions_0.1.2  
[109] RcppAnnoy_0.0.19      cowplot_1.1.1         irlba_2.3.5          
[112] httpuv_1.6.5          patchwork_1.1.1       R6_2.5.1             
[115] promises_1.2.0.1      KernSmooth_2.23-20    IRanges_2.30.0       
[118] parallelly_1.31.1     codetools_0.2-18      MASS_7.3-56          
[121] assertthat_0.2.1      rprojroot_2.0.3       rjson_0.2.21         
[124] withr_2.5.0           sctransform_0.3.3     S4Vectors_0.34.0     
[127] mgcv_1.8-40           parallel_4.2.0        rpart_4.1.16         
[130] tidyr_1.2.0           rmarkdown_2.14        Rtsne_0.16           
[133] git2r_0.30.1          getPass_0.2-2         shiny_1.7.1