Last updated: 2022-09-16
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 2108dae. 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: .Rhistory
Ignored: .Rproj.user/
Untracked files:
Untracked: Rplots.pdf
Untracked: analysis/check_Tcells_datasets.Rmd
Untracked: analysis/fscLVM_analysis.Rmd
Untracked: analysis/interpret_gsfa_TCells.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/index.Rmd
Modified: analysis/music_LUHMES_data.Rmd
Modified: analysis/sceptre_LUHMES_data.Rmd
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/interpret_gsfa_LUHMES.Rmd
)
and HTML (docs/interpret_gsfa_LUHMES.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 | 2108dae | kevinlkx | 2022-09-16 | updated sceptre result |
This tutorial demonstrates how to visualize and interpret the results from a GSFA run.
The results are a bit different from what was reported in the biorxiv version of GSFA manuscript due to slight changes in random sampling and calibration of negative control effects.
We have described how to run GSFA on LUHMES CROP-seq data here.
To recapitulate, the processed dataset consists of 8708 neural progenitor cells that belong to one of the 15 perturbation conditions (CRISPR knock-down of 14 neurodevelopmental genes, and negative control). Top 6000 genes ranked by deviance statistics were kept. And GSFA was performed on the data with 20 factors specified.
library(data.table)
library(Matrix)
library(tidyverse)
library(ggplot2)
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 = 12),
legend.title = element_text(size = 13),
legend.text = element_text(size = 12),
panel.grid.minor = element_blank())
)
library(gridExtra)
library(ComplexHeatmap)
library(kableExtra)
library(WebGestaltR)
source("/project2/xinhe/yifan/Factor_analysis/analysis_website_for_Kevin/scripts/plotting_functions.R")
data_folder <- "/project2/xinhe/yifan/Factor_analysis/LUHMES/"
The first thing we need is the output of GSFA
fit_gsfa_multivar()
run. The lighter version containing
just the posterior mean estimates and LFSR of perturbation-gene effects
is enough.
fit <- readRDS(paste0(data_folder,
"gsfa_output_detect_01/use_negctrl/All.gibbs_obj_k20.svd_negctrl.seed_14314.light.rds"))
gibbs_PM <- fit$posterior_means
lfsr_mat <- fit$lfsr[, -ncol(fit$lfsr)]
total_effect <- fit$total_effect[, -ncol(fit$total_effect)]
KO_names <- colnames(lfsr_mat)
We also need the cell by perturbation matrix which was used as input \(G\) for GSFA.
metadata <- readRDS(paste0(data_folder, "processed_data/merged_metadata.rds"))
G_mat <- metadata[, 4:18]
Finally, we load the mapping from gene name to ENSEMBL ID for all 6k genes used in GSFA, as well as selected neuronal marker genes. This is specific to this study and analysis.
feature.names <- data.frame(fread(paste0(data_folder, "GSE142078_raw/GSM4219576_Run2_genes.tsv.gz"),
header = FALSE), stringsAsFactors = FALSE)
genes_df <- feature.names[match(rownames(lfsr_mat), feature.names$V1), ]
names(genes_df) <- c("ID", "Name")
interest_df <- readRDS(paste0(data_folder, "processed_data/selected_neuronal_markers.rds"))
Fisrt of all, we look at the estimated effects of gene perturbations on factors inferred by GSFA.
We found that targeting of 7 genes, ADNP, ARID1B, ASH1L, CHD2, DYRK1A, PTEN, and SETD5, has significant effects (PIP > 0.95) on at least 1 of the 20 inferred factors.
All targets and factors (Figure S6A):
dotplot_beta_PIP(t(gibbs_PM$Gamma_pm), t(gibbs_PM$beta_pm),
marker_names = KO_names,
reorder_markers = c(KO_names[KO_names!="Nontargeting"], "Nontargeting"),
inverse_factors = F) +
coord_flip()
## Similar visualization using GSFA built-in functions:
GSFA::dotplot_beta_PIP(fit,
target_names = KO_names,
reorder_targets = c(KO_names[KO_names!="Nontargeting"], "Nontargeting"))
Here is a closer look at the estimated effects of selected perturbations on selected factors (Figure 5A):
targets <- c("ADNP", "ARID1B", "ASH1L", "CHD2", "DYRK1A", "PTEN", "SETD5")
complexplot_perturbation_factor(gibbs_PM$Gamma_pm[-nrow(gibbs_PM$Gamma_pm), ],
gibbs_PM$beta_pm[-nrow(gibbs_PM$beta_pm), ],
marker_names = KO_names,
reorder_markers = targets,
reorder_factors = c(6, 9, 15))
## Similar visualization using GSFA built-in functions:
GSFA::dotplot_beta_PIP(fit,
target_names = KO_names,
reorder_targets = targets, reorder_factors = c(6, 9, 15))
We can also assess the correlations between each pair of perturbation
and inferred factor.
The distribution of correlation p values show significant signals.
gibbs_res_tb <- make_gibbs_res_tb(gibbs_PM, G_mat, compute_pve = F)
heatmap_matrix <- gibbs_res_tb %>% select(starts_with("pval"))
rownames(heatmap_matrix) <- 1:nrow(heatmap_matrix)
colnames(heatmap_matrix) <- colnames(G_mat)
summ_pvalues(unlist(heatmap_matrix),
title_text = "GSFA\n(15 Targets x 20 Factors)")
Since the GSFA model does not enforce orthogonality among factors, we first inspect the pairwise correlation within them to see if there is any redundancy. As we can see below, the inferred factors are mostly independent of each other.
plot_pairwise.corr_heatmap(input_mat_1 = gibbs_PM$Z_pm,
corr_type = "pearson",
name_1 = "Pairwise correlation within factors (Z)",
label_size = 10)
plot_pairwise.corr_heatmap(input_mat_1 = (gibbs_PM$F_pm > 0.95) * 1,
corr_type = "jaccard",
name_1 = "Pairwise correlation within \nbinarized gene loadings (F_pm > 0.95)",
label_size = 10)
To understand these latent factors, we inspect the loadings (weights) of several marker genes for neuron maturation and differentiation in them.
protein_name | gene_name | type | gene_ID |
---|---|---|---|
TP53 | TP53 | Cell proliferation | ENSG00000141510 |
CDK4 | CDK4 | Cell proliferation | ENSG00000135446 |
Nestin | NES | Neural progenitor cell | ENSG00000132688 |
STMN2 | STMN2 | Mature neuron | ENSG00000104435 |
MAP2 | MAP2 | Mature neuron | ENSG00000078018 |
DPYSL3 | DPYSL3 | Mature neuron | ENSG00000113657 |
MAP1B | MAP1B | Mature neuron | ENSG00000131711 |
CRABP2 | CRABP2 | Mature neuron | ENSG00000143320 |
NEFL | NEFL | Mature neuron | ENSG00000277586 |
ZEB2 | ZEB2 | Mature neuron | ENSG00000169554 |
ITM2C | ITM2C | Negative regulation of neuron projection | ENSG00000135916 |
CNTN2 | CNTN2 | Negative regulation of neuron projection | ENSG00000184144 |
DRAXIN | DRAXIN | Negative regulation of neuron projection | ENSG00000162490 |
HDAC2 | HDAC2 | Negative regulation of neuron projection | ENSG00000196591 |
We visualize both the gene PIPs (dot size) and gene weights (dot color) in all factors (Figure S6B):
complexplot_gene_factor(genes_df, interest_df, gibbs_PM$F_pm, gibbs_PM$W_pm)
A closer look at some factors that are associated with perturbations (Figure 5C):
complexplot_gene_factor(genes_df, interest_df, gibbs_PM$F_pm, gibbs_PM$W_pm,
reorder_factors = c(6, 9, 15))
To further characterize these latent factors, we perform GO (gene
ontology) enrichment analysis of genes loaded on the factors using
WebGestalt
.
Foreground genes: genes w/ non-zero loadings in each factor (gene PIP
> 0.95);
Background genes: all 6000 genes used in GSFA;
Statistical test: hypergeometric test (over-representation test);
Gene sets: GO Slim “Biological Process” (non-redundant).
## The "WebGestaltR" tool needs Internet connection.
enrich_db <- "geneontology_Biological_Process_noRedundant"
PIP_mat <- gibbs_PM$F_pm
enrich_res_by_factor <- list()
for (i in 1:ncol(PIP_mat)){
enrich_res_by_factor[[i]] <-
WebGestaltR::WebGestaltR(enrichMethod = "ORA",
organism = "hsapiens",
enrichDatabase = enrich_db,
interestGene = genes_df[PIP_mat[, i] > 0.95, ]$ID,
interestGeneType = "ensembl_gene_id",
referenceGene = genes_df$ID,
referenceGeneType = "ensembl_gene_id",
isOutput = F)
}
Several GO “biological process” terms related to neuronal development are enriched in factors 4, 9, and 16 (Figure 5D):
factor_indx <- 6
terms_of_interest <- c("regulation of ion transmembrane transport",
"regulation of trans-synaptic signaling",
"axon development",
"regulation of neuron projection development")
barplot_top_enrich_terms(enrich_res_by_factor[[factor_indx]],
terms_of_interest = terms_of_interest,
str_wrap_length = 35, pval_max = 8, FC_max = 6) +
labs(title = paste0("Factor ", factor_indx),
x = "Fold of enrichment")
factor_indx <- 9
terms_of_interest <- c("actin filament organization",
"cell fate commitment",
"axon development",
"regulation of cell morphogenesis")
barplot_top_enrich_terms(enrich_res_by_factor[[factor_indx]],
terms_of_interest = terms_of_interest,
str_wrap_length = 35, pval_max = 8, FC_max = 6) +
labs(title = paste0("Factor ", factor_indx),
x = "Fold of enrichment")
factor_indx <- 15
terms_of_interest <- c("developmental growth involved in morphogenesis",
"axon development")
barplot_top_enrich_terms(enrich_res_by_factor[[factor_indx]],
terms_of_interest = terms_of_interest,
str_wrap_length = 35, pval_max = 8, FC_max = 6) +
labs(title = paste0("Factor ", factor_indx),
x = "Fold of enrichment")
In GSFA, differential expression analysis can be performed based on the LFSR method. Here we evaluate the specific downstream genes affected by the perturbations detected by GSFA.
We also performed several other differential expression methods for comparison, including scMAGeCK-LR, MAST, and DESeq.
fdr_cutoff <- 0.05
lfsr_cutoff <- 0.05
KO | ADNP | ARID1B | ASH1L | CHD2 | CHD8 |
Num_genes | 795 | 310 | 322 | 756 | 0 |
KO | CTNND2 | DYRK1A | HDAC5 | MECP2 | MYT1L |
Num_genes | 0 | 23 | 0 | 0 | 0 |
KO | Nontargeting | POGZ | PTEN | RELN | SETD5 |
Num_genes | 0 | 0 | 895 | 0 | 466 |
guides <- KO_names[KO_names!="Nontargeting"]
deseq_list <- list()
for (m in guides){
fname <- paste0(data_folder, "processed_data/DESeq2/dev_top6k_negctrl/gRNA_",
m, ".dev_res_top6k.vs_negctrl.rds")
res <- readRDS(fname)
res <- as.data.frame(res@listData, row.names = res@rownames)
res$geneID <- rownames(res)
res <- res %>% dplyr::rename(FDR = padj, PValue = pvalue)
deseq_list[[m]] <- res
}
deseq_signif_counts <- sapply(deseq_list, function(x){filter(x, FDR < fdr_cutoff) %>% nrow()})
mast_list <- list()
for (m in guides){
fname <- paste0(data_folder, "processed_data/MAST/dev_top6k_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()})
scmageck_res <- readRDS(paste0(data_folder, "scmageck/scmageck_lr.LUHMES.dev_res_top_6k.rds"))
colnames(scmageck_res$fdr)[colnames(scmageck_res$fdr) == "NegCtrl"] <- "Nontargeting"
scmageck_signif_counts <- colSums(scmageck_res$fdr[, KO_names] < fdr_cutoff)
scmageck_signif_counts <- scmageck_signif_counts[names(scmageck_signif_counts) != "Nontargeting"]
sceptre_res <- readRDS("/project2/xinhe/kevinluo/GSFA/sceptre_analysis/LUHMES_data_updated/sceptre_output/sceptre.result.rds")
sceptre_count_df <- data.frame(matrix(nrow = length(guides), ncol = 2))
colnames(sceptre_count_df) <- c("target", "num_DEG")
for (i in 1:length(guides)){
sceptre_count_df$target[i] <- guides[i]
tmp_pval <- sceptre_res %>% filter(gRNA_id == guides[i]) %>% pull(p_value)
tmp_fdr <- p.adjust(tmp_pval, method = "fdr")
sceptre_count_df$num_DEG[i] <- sum(tmp_fdr < 0.05)
}
dge_comparison_df <- data.frame(Perturbation = guides,
GSFA = lfsr_signif_num[guides],
scMAGeCK = scmageck_signif_counts,
DESeq2 = deseq_signif_counts,
MAST = mast_signif_counts,
SCEPTRE = sceptre_count_df$num_DEG)
# dge_comparison_df$Perturbation[dge_comparison_df$Perturbation == "Nontargeting"] <- "NegCtrl"
Number of DEGs detected under each perturbation using 4 different methods (Figure 5E):
Compared with other differential expression analysis methods, GSFA detected the most DEGs for all 7 gene targets that have significant effects.
dge_plot_df <- reshape2::melt(dge_comparison_df, id.var = "Perturbation",
variable.name = "Method", value.name = "Num_DEGs")
dge_plot_df$Perturbation <- factor(dge_plot_df$Perturbation,
levels = guides)
# levels = c("NegCtrl", KO_names[KO_names!="Nontargeting"]))
ggplot(dge_plot_df, aes(x = Perturbation, y = Num_DEGs+1, fill = Method)) +
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 different methods") +
theme(axis.text.x = element_text(angle = 45, hjust = 1, size = 12),
legend.position = "bottom",
legend.text = element_text(size = 13))
To better understand the functions of these 7 target genes, we examined their effects on marker genes for neuron maturation and differentiation.
Here are the summarized effects of perturbations on marker genes estimated by GSFA (Figure 5G).
As we can see, knockdown of ADNP, ASH1L, CHD2, and DYRK1A has mostly negative effects on mature neuronal markers, and positive effects on negative regulators of neuron projection, indicating delayed neuron maturation.
Knockdown of PTEN and SETD5 has the opposite pattern, which indicates accelerated neuron maturation.
targets <- c("ADNP", "ARID1B", "ASH1L", "CHD2", "DYRK1A", "PTEN", "SETD5")
complexplot_gene_perturbation(genes_df, interest_df,
targets = targets,
lfsr_mat = lfsr_mat,
effect_mat = total_effect)
## Similar visualization using GSFA built-in functions:
GSFA::dotplot_total_effect(fit,
gene_indices = match(interest_df$gene_ID, rownames(lfsr_mat)),
gene_names = interest_df$gene_name,
reorder_targets = targets,
plot_max_score = 0.2)
Here are scMAGeCK estimated effects of perturbations on marker genes (Figure 5H):
score_mat <- scmageck_res$score
fdr_mat <- scmageck_res$fdr
complexplot_gene_perturbation(genes_df, interest_df,
targets = targets,
lfsr_mat = fdr_mat, lfsr_name = "FDR",
effect_mat = score_mat, effect_name = "scMAGeCK\nselection score",
score_break = c(-0.2, 0, 0.2),
color_break = c("blue3", "grey90", "red3"))
FC_mat <- matrix(nrow = nrow(interest_df), ncol = length(targets))
rownames(FC_mat) <- interest_df$gene_name
colnames(FC_mat) <- targets
fdr_mat <- FC_mat
for (m in targets){
FC_mat[, m] <- deseq_list[[m]]$log2FoldChange[match(interest_df$gene_ID,
deseq_list[[m]]$geneID)]
fdr_mat[, m] <- deseq_list[[m]]$FDR[match(interest_df$gene_ID, deseq_list[[m]]$geneID)]
}
Here are DESeq2 estimated effects of perturbations on marker genes (Figure S5C):
complexplot_gene_perturbation(genes_df, interest_df,
targets = targets,
lfsr_mat = fdr_mat, lfsr_name = "FDR",
effect_mat = FC_mat, effect_name = "DESeq2 log2FC",
score_break = c(-0.4, 0, 0.4),
color_break = c("blue3", "grey90", "red3"))
FC_mat <- matrix(nrow = nrow(interest_df), ncol = length(targets))
rownames(FC_mat) <- interest_df$gene_name
colnames(FC_mat) <- targets
fdr_mat <- FC_mat
for (m in targets){
FC_mat[, m] <- mast_list[[m]]$logFC[match(interest_df$gene_ID, mast_list[[m]]$geneID)]
fdr_mat[, m] <- mast_list[[m]]$FDR[match(interest_df$gene_ID, mast_list[[m]]$geneID)]
}
MAST estimated effects of perturbations on marker genes (Figure S5D):
complexplot_gene_perturbation(genes_df, interest_df,
targets = targets,
lfsr_mat = fdr_mat, lfsr_name = "FDR",
effect_mat = FC_mat, effect_name = "MAST logFC",
score_break = c(-0.4, 0, 0.4),
color_break = c("blue3", "grey90", "red3"))
FC_mat <- matrix(nrow = nrow(interest_df), ncol = length(targets))
rownames(FC_mat) <- interest_df$gene_name
colnames(FC_mat) <- targets
fdr_mat <- FC_mat
for (m in targets){
sceptre_tmp_res <- sceptre_res %>% filter(gRNA_id == m)
tmp_pval <- sceptre_tmp_res %>% pull(p_value)
sceptre_tmp_res$FDR <- p.adjust(tmp_pval, method = "fdr")
FC_mat[, m] <- sceptre_tmp_res$log_fold_change[match(interest_df$gene_ID,
sceptre_tmp_res$gene_id)]
fdr_mat[, m] <- sceptre_tmp_res$FDR[match(interest_df$gene_ID,
sceptre_tmp_res$gene_id)]
}
SCEPTRE estimated effects of perturbations on marker genes (Figure S5):
complexplot_gene_perturbation(genes_df, interest_df,
targets = targets,
lfsr_mat = fdr_mat, lfsr_name = "FDR",
effect_mat = FC_mat, effect_name = "SCEPTRE logFC",
score_break = c(-0.4, 0, 0.4),
color_break = c("blue3", "grey90", "red3"))
We further examine these DEGs for enrichment of relevant biological processes through GO enrichment analysis.
Foreground genes: Genes w/ GSFA LFSR < 0.05 under each
perturbation;
Background genes: all 6000 genes used in GSFA;
Statistical test: hypergeometric test (over-representation test);
Gene sets: Gene ontology “Biological Process” (non-redundant).
## The "WebGestaltR" tool needs Internet connection.
targets <- names(lfsr_signif_num)[lfsr_signif_num > 0]
enrich_db <- "geneontology_Biological_Process_noRedundant"
enrich_res <- list()
for (i in targets){
print(i)
interest_genes <- genes_df %>% mutate(lfsr = lfsr_mat[, i]) %>%
filter(lfsr < lfsr_cutoff) %>% pull(ID)
enrich_res[[i]] <-
WebGestaltR::WebGestaltR(enrichMethod = "ORA",
organism = "hsapiens",
enrichDatabase = enrich_db,
interestGene = interest_genes,
interestGeneType = "ensembl_gene_id",
referenceGene = genes_df$ID,
referenceGeneType = "ensembl_gene_id",
isOutput = F)
}
signif_GO_list <- list()
for (i in names(enrich_res)) {
signif_GO_list[[i]] <- enrich_res[[i]] %>%
dplyr::filter(FDR < 0.05) %>%
dplyr::select(geneSet, description, size, enrichmentRatio, pValue) %>%
mutate(target = i)
}
signif_term_df <- do.call(rbind, signif_GO_list) %>%
group_by(geneSet, description, size) %>%
summarise(pValue = min(pValue)) %>%
ungroup()
abs_FC_colormap <- circlize::colorRamp2(breaks = c(0, 3, 6),
colors = c("grey95", "#77d183", "#255566"))
targets <- names(enrich_res)
enrich_table <- data.frame(matrix(nrow = nrow(signif_term_df),
ncol = length(targets)),
row.names = signif_term_df$geneSet)
colnames(enrich_table) <- targets
for (i in 1:ncol(enrich_table)){
m <- colnames(enrich_table)[i]
enrich_df <- enrich_res[[m]] %>% dplyr::filter(FDR < 0.05)
enrich_table[enrich_df$geneSet, i] <- enrich_df$enrichmentRatio
}
rownames(enrich_table) <- signif_term_df$description
Here are selected GO “biological process” terms and their folds of
enrichment in DEGs detected by GSFA (Figure S5E):
(In the code below, we omitted the content in
terms_of_interest_df
as one can subset the
enrich_table
with any terms of their choice.)
interest_enrich_table <- enrich_table[terms_of_interest_df$description,
colnames(enrich_table) != "DYRK1A"]
interest_enrich_table[is.na(interest_enrich_table)] <- 0
map <- Heatmap(abs(interest_enrich_table),
name = "Fold of enrichment",
col = abs_FC_colormap,
na_col = "grey90",
row_title = NULL, column_title = NULL,
cluster_rows = F, cluster_columns = F,
show_row_dend = F, show_column_dend = F,
show_heatmap_legend = T,
row_names_gp = gpar(fontsize = 10.5),
column_names_rot = 45,
column_names_side = "top",
width = unit(6, "cm"))
draw(map, heatmap_legend_side = "bottom")
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 WebGestaltR_0.4.4 kableExtra_1.3.4
[4] ComplexHeatmap_2.12.0 gridExtra_2.3 forcats_0.5.1
[7] stringr_1.4.0 dplyr_1.0.9 purrr_0.3.4
[10] readr_2.1.2 tidyr_1.2.0 tibble_3.1.7
[13] ggplot2_3.3.6 tidyverse_1.3.1 Matrix_1.4-1
[16] data.table_1.14.2 workflowr_1.7.0
loaded via a namespace (and not attached):
[1] colorspace_2.0-3 rjson_0.2.21 ellipsis_0.3.2
[4] rprojroot_2.0.3 circlize_0.4.15 GlobalOptions_0.1.2
[7] fs_1.5.2 clue_0.3-61 rstudioapi_0.13
[10] farver_2.1.0 fansi_1.0.3 lubridate_1.8.0
[13] xml2_1.3.3 codetools_0.2-18 R.methodsS3_1.8.1
[16] doParallel_1.0.17 knitr_1.39 jsonlite_1.8.0
[19] apcluster_1.4.10 Cairo_1.6-0 broom_0.8.0
[22] cluster_2.1.3 dbplyr_2.1.1 png_0.1-7
[25] R.oo_1.24.0 compiler_4.2.0 httr_1.4.3
[28] backports_1.4.1 assertthat_0.2.1 fastmap_1.1.0
[31] cli_3.3.0 later_1.3.0 htmltools_0.5.2
[34] tools_4.2.0 igraph_1.3.4 gtable_0.3.0
[37] glue_1.6.2 reshape2_1.4.4 doRNG_1.8.2
[40] Rcpp_1.0.8.3 cellranger_1.1.0 jquerylib_0.1.4
[43] vctrs_0.4.1 svglite_2.1.0 iterators_1.0.14
[46] xfun_0.30 ps_1.7.0 rvest_1.0.2
[49] lifecycle_1.0.1 rngtools_1.5.2 getPass_0.2-2
[52] scales_1.2.0 hms_1.1.1 promises_1.2.0.1
[55] parallel_4.2.0 RColorBrewer_1.1-3 yaml_2.3.5
[58] pander_0.6.5 sass_0.4.1 stringi_1.7.6
[61] highr_0.9 S4Vectors_0.34.0 foreach_1.5.2
[64] BiocGenerics_0.42.0 shape_1.4.6 rlang_1.0.2
[67] pkgconfig_2.0.3 systemfonts_1.0.4 matrixStats_0.62.0
[70] evaluate_0.15 labeling_0.4.2 processx_3.5.3
[73] tidyselect_1.1.2 plyr_1.8.7 magrittr_2.0.3
[76] R6_2.5.1 IRanges_2.30.0 generics_0.1.2
[79] DBI_1.1.3 pillar_1.7.0 haven_2.5.0
[82] whisker_0.4 withr_2.5.0 modelr_0.1.8
[85] crayon_1.5.1 utf8_1.2.2 tzdb_0.3.0
[88] rmarkdown_2.14 GetoptLong_1.0.5 readxl_1.4.0
[91] callr_3.7.0 git2r_0.30.1 reprex_2.0.1
[94] digest_0.6.29 webshot_0.5.3 httpuv_1.6.5
[97] R.utils_2.11.0 stats4_4.2.0 munsell_0.5.0
[100] viridisLite_0.4.0 bslib_0.3.1
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 WebGestaltR_0.4.4
kableExtra_1.3.4
[4] ComplexHeatmap_2.12.0 gridExtra_2.3 forcats_0.5.1
[7] stringr_1.4.0 dplyr_1.0.9 purrr_0.3.4
[10] readr_2.1.2 tidyr_1.2.0 tibble_3.1.7
[13] ggplot2_3.3.6 tidyverse_1.3.1 Matrix_1.4-1
[16] data.table_1.14.2 workflowr_1.7.0
loaded via a namespace (and not attached): [1] colorspace_2.0-3
rjson_0.2.21 ellipsis_0.3.2
[4] rprojroot_2.0.3 circlize_0.4.15 GlobalOptions_0.1.2 [7] fs_1.5.2
clue_0.3-61 rstudioapi_0.13
[10] farver_2.1.0 fansi_1.0.3 lubridate_1.8.0
[13] xml2_1.3.3 codetools_0.2-18 R.methodsS3_1.8.1
[16] doParallel_1.0.17 knitr_1.39 jsonlite_1.8.0
[19] apcluster_1.4.10 Cairo_1.6-0 broom_0.8.0
[22] cluster_2.1.3 dbplyr_2.1.1 png_0.1-7
[25] R.oo_1.24.0 compiler_4.2.0 httr_1.4.3
[28] backports_1.4.1 assertthat_0.2.1 fastmap_1.1.0
[31] cli_3.3.0 later_1.3.0 htmltools_0.5.2
[34] tools_4.2.0 igraph_1.3.4 gtable_0.3.0
[37] glue_1.6.2 reshape2_1.4.4 doRNG_1.8.2
[40] Rcpp_1.0.8.3 cellranger_1.1.0 jquerylib_0.1.4
[43] vctrs_0.4.1 svglite_2.1.0 iterators_1.0.14
[46] xfun_0.30 ps_1.7.0 rvest_1.0.2
[49] lifecycle_1.0.1 rngtools_1.5.2 getPass_0.2-2
[52] scales_1.2.0 hms_1.1.1 promises_1.2.0.1
[55] parallel_4.2.0 RColorBrewer_1.1-3 yaml_2.3.5
[58] pander_0.6.5 sass_0.4.1 stringi_1.7.6
[61] highr_0.9 S4Vectors_0.34.0 foreach_1.5.2
[64] BiocGenerics_0.42.0 shape_1.4.6 rlang_1.0.2
[67] pkgconfig_2.0.3 systemfonts_1.0.4 matrixStats_0.62.0 [70]
evaluate_0.15 labeling_0.4.2 processx_3.5.3
[73] tidyselect_1.1.2 plyr_1.8.7 magrittr_2.0.3
[76] R6_2.5.1 IRanges_2.30.0 generics_0.1.2
[79] DBI_1.1.3 pillar_1.7.0 haven_2.5.0
[82] whisker_0.4 withr_2.5.0 modelr_0.1.8
[85] crayon_1.5.1 utf8_1.2.2 tzdb_0.3.0
[88] rmarkdown_2.14 GetoptLong_1.0.5 readxl_1.4.0
[91] callr_3.7.0 git2r_0.30.1 reprex_2.0.1
[94] digest_0.6.29 webshot_0.5.3 httpuv_1.6.5
[97] R.utils_2.11.0 stats4_4.2.0 munsell_0.5.0
[100] viridisLite_0.4.0 bslib_0.3.1