Last updated: 2022-03-24

Checks: 4 3

Knit directory: MS_lesions/

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.


The R Markdown file has unstaged changes. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

The global environment had objects present when the code in the R Markdown file was run. These objects 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. Use wflow_publish or wflow_build to ensure that the code is always run in an empty environment.

The following objects were defined in the global environment when these results were created:

Name Class Size
q function 1008 bytes

The command set.seed(20210118) 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.

The following chunks had caches available:
  • setup_input
  • setup_outputs

To ensure reproducibility of the results, delete the cache directory ms15_mofa_wm_edger_libs_cache and re-run the analysis. To have workflowr automatically delete the cache directory prior to building the file, set delete_cache = TRUE when running wflow_build() or wflow_publish().

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 9175fdc. 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:    .RData
    Ignored:    .Rhistory
    Ignored:    .Rprofile
    Ignored:    .Rproj.user/
    Ignored:    ._F12_wm_chk.png
    Ignored:    ._MS_lesions.sublime-project
    Ignored:    ._fxs_genes.png
    Ignored:    .log/
    Ignored:    MS_lesions.sublime-project
    Ignored:    MS_lesions.sublime-workspace
    Ignored:    analysis/.__site.yml
    Ignored:    analysis/fig_muscat_cache/
    Ignored:    analysis/ms00_manuscript_figures_cache/
    Ignored:    analysis/ms02_doublet_id_cache/
    Ignored:    analysis/ms03_SampleQC_cache/
    Ignored:    analysis/ms03_SampleQC_summary_cache/
    Ignored:    analysis/ms04_conos_cache/
    Ignored:    analysis/ms05_splitting_cache/
    Ignored:    analysis/ms06_sccaf_cache/
    Ignored:    analysis/ms07_soup_cache/
    Ignored:    analysis/ms08_modules_cache/
    Ignored:    analysis/ms08_modules_pseudobulk_cache/
    Ignored:    analysis/ms09_ancombc_cache/
    Ignored:    analysis/ms09_ancombc_clean_1e3_cache/
    Ignored:    analysis/ms09_ancombc_clean_2e3_cache/
    Ignored:    analysis/ms09_ancombc_mixed_cache/
    Ignored:    analysis/ms10_muscat_run01_cache/
    Ignored:    analysis/ms10_muscat_run02_cache/
    Ignored:    analysis/ms10_muscat_template_broad_slim_cache/
    Ignored:    analysis/ms10_muscat_template_fine_slim_cache/
    Ignored:    analysis/ms11_paga_cache/
    Ignored:    analysis/ms11_paga_recalc_cache/
    Ignored:    analysis/ms11_paga_superclean_cache/
    Ignored:    analysis/ms12_markers_cache/
    Ignored:    analysis/ms13_labelling_cache/
    Ignored:    analysis/ms14_lesions_cache/
    Ignored:    analysis/ms15_mofa_gm_cache/
    Ignored:    analysis/ms15_mofa_gm_edger_libs_cache/
    Ignored:    analysis/ms15_mofa_heatmaps_cache/
    Ignored:    analysis/ms15_mofa_sample_gm_cache/
    Ignored:    analysis/ms15_mofa_sample_gm_final_meta_cache/
    Ignored:    analysis/ms15_mofa_sample_gm_superclean_cache/
    Ignored:    analysis/ms15_mofa_sample_gm_w_layers_final_meta_cache/
    Ignored:    analysis/ms15_mofa_sample_wm_cache/
    Ignored:    analysis/ms15_mofa_sample_wm_final_meta_bigger_cache/
    Ignored:    analysis/ms15_mofa_sample_wm_final_meta_bigger_edger_libsizes_cache/
    Ignored:    analysis/ms15_mofa_sample_wm_final_meta_cache/
    Ignored:    analysis/ms15_mofa_sample_wm_final_meta_edger_libsizes_cache/
    Ignored:    analysis/ms15_mofa_sample_wm_final_meta_neuro_ok_cache/
    Ignored:    analysis/ms15_mofa_sample_wm_new_meta_cache/
    Ignored:    analysis/ms15_mofa_sample_wm_superclean_cache/
    Ignored:    analysis/ms15_mofa_wm_bigger_cache/
    Ignored:    analysis/ms15_mofa_wm_cache/
    Ignored:    analysis/ms15_mofa_wm_coding_only_bigger_cache/
    Ignored:    analysis/ms15_mofa_wm_coding_only_cache/
    Ignored:    analysis/ms15_mofa_wm_edger_libs_cache/
    Ignored:    analysis/ms15_mofa_wm_neuro_ok_cache/
    Ignored:    analysis/ms15_mofa_wm_pearson_cache/
    Ignored:    analysis/ms15_patients_cache/
    Ignored:    analysis/ms15_patients_gm_cache/
    Ignored:    analysis/ms15_patients_sample_level_cache/
    Ignored:    analysis/ms15_patients_w_ms_cache/
    Ignored:    analysis/ms99_deg_figures_gm_cache/
    Ignored:    analysis/ms99_deg_figures_wm_cache/
    Ignored:    analysis/ms99_manuscript_figures_cache/
    Ignored:    analysis/ms99_test_cache/
    Ignored:    analysis/public/
    Ignored:    analysis/supp06_sccaf_cache/
    Ignored:    analysis/supp07_superclean_check_cache/
    Ignored:    analysis/supp09_ancombc_cache/
    Ignored:    analysis/supp09_ancombc_mixed_cache/
    Ignored:    analysis/supp09_ancombc_rowitch_cache/
    Ignored:    analysis/supp09_ancombc_superclean_cache/
    Ignored:    analysis/supp10_muscat_cache/
    Ignored:    analysis/supp10_muscat_ctrl_gm_vs_wm_cache/
    Ignored:    analysis/supp10_muscat_gm_layers_effects_cache/
    Ignored:    analysis/supp10_muscat_gsea_cache/
    Ignored:    analysis/supp10_muscat_heatmaps_cache/
    Ignored:    analysis/supp10_muscat_olg_pc1_cache/
    Ignored:    analysis/supp10_muscat_olg_pc2_cache/
    Ignored:    analysis/supp10_muscat_olg_pc_cache/
    Ignored:    analysis/supp10_muscat_regression_cache/
    Ignored:    analysis/supp10_muscat_soup_cache/
    Ignored:    analysis/supp10_muscat_soup_mito_cache/
    Ignored:    code/._ms10_muscat_fns_recover.R
    Ignored:    code/.recovery/
    Ignored:    code/adhoc_code/
    Ignored:    code/jobs/._muscat_run09_2021-10-11.slurm
    Ignored:    data/
    Ignored:    figures/
    Ignored:    output/
    Ignored:    tmp/

Untracked files:
    Untracked:  %
    Untracked:  check_absolutes.png
    Untracked:  wm_vs_gm.png

Unstaged changes:
    Modified:   analysis/ms09_ancombc_mixed.Rmd
    Modified:   analysis/ms15_mofa_gm_edger_libs.Rmd
    Modified:   analysis/ms15_mofa_wm_edger_libs.Rmd
    Modified:   code/ms00_utils.R
    Modified:   code/ms09_ancombc_mixed.R
    Modified:   code/ms15_mofa.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/ms15_mofa_wm_edger_libs.Rmd) and HTML (public/ms15_mofa_wm_edger_libs.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 b677f1a Macnair 2022-03-23 Add “already done?” check to MOFA rmd
Rmd 91ab359 Will Macnair 2022-03-23 Tweak MOFA analysis
html 91ab359 Will Macnair 2022-03-23 Tweak MOFA analysis
Rmd 7c17d96 Macnair 2022-03-18 Add various MOFA run outputs
html 7c17d96 Macnair 2022-03-18 Add various MOFA run outputs
Rmd 74935aa wmacnair 2022-03-06 Fix MOFA WM, update some plots
html 74935aa wmacnair 2022-03-06 Fix MOFA WM, update some plots

Setup / definitions

Libraries

Helper functions

source('code/ms00_utils.R')
source('code/ms08_modules.R')
source('code/ms09_ancombc.R')
source('code/ms10_muscat_runs.R')
source('code/ms15_mofa.R')
n_cores     = 8
setDTthreads(n_cores)

Inputs

# specify what goes into muscat run
meta_f      = "data/metadata/metadata_checked_assumptions_2022-03-22.xlsx"
olg_grps_f  = 'data/metadata/oligo_groupings.txt'
labels_f    = 'data/byhand_markers/validation_markers_2021-05-31.csv'
labelled_f  = 'output/ms13_labelling/conos_labelled_2021-05-31.txt.gz'
pb_f        = file.path(soup_dir, 'pb_sum_broad_2021-10-11.rds')
pb_fine_f   = file.path(soup_dir, 'pb_sum_fine_2021-10-11.rds')
soup_f      = 'data/ambient/ambient.100UMI.txt'

# file with gene biotypes
gtf_f       = 'data/gtf/Homo_sapiens.GRCh38.96.filtered.preMRNA.gtf'

# get summary QC metrics for each sample
qc_dir      = "output/ms03_SampleQC"
qc_f        = file.path(qc_dir, "ms_qc_dt.txt")

# define run to load
run_tag     = 'run09'
time_stamp  = '2021-10-13'

# define files
model_dir   = file.path('output/ms10_muscat', run_tag)
muscat_f    = '%s/muscat_res_dt_%s_%s.txt.gz' %>%
  sprintf(model_dir, run_tag, time_stamp)
anova_f     = '%s/muscat_goodness_dt_%s_%s.txt.gz' %>%
  sprintf(model_dir, run_tag, time_stamp)
params_f    = '%s/muscat_params_%s_%s.rds' %>%
  sprintf(model_dir, run_tag, time_stamp)
ranef_dt_f  = sprintf('%s/muscat_ranef_dt_%s_%s.txt.gz', 
  model_dir, run_tag, time_stamp)
mds_sep_f   = sprintf('%s/mds_sep_dt_%s_%s.txt.gz', 
  model_dir, run_tag, time_stamp)

Outputs

# where to save
save_dir    = 'output/ms15_mofa'
date_tag    = '2022-03-03_edger'
if (!dir.exists(save_dir))
  dir.create(save_dir)

# file for summary of QC metrics
qc_stats_f  = sprintf('%s/qc_stats_by_sample_%s.txt', save_dir, date_tag)

# parameters for gene selection
min_sd      = log(2)
min_fc      = log(2)
max_p       = 0.01
n_factors   = 5
sel_cl      = c("OPCs / COPs", "Oligodendrocytes", "Astrocytes", "Microglia", 
  "Endothelial cells", "Pericytes", "Immune")
fgsea_cut   = 0.1
sel_ps      = c('go_bp', 'go_cc', 'go_mf', 'hallmark', 'kegg')
log_p_mad   = 2
n_paths     = 50

# parameters for plotting
min_var     = 5
w_cut       = 0.2

# checking if metadata can explain factors
formula_str = '~ lesion_type + sex + age_scale + pmi_cat'
random_var  = 'subject_orig'

# restriction to protein-coding genes only for expression heatmaps
ok_types    = c('protein_coding', 'IG_V_gene', 'IG_C_gene', 'IG_J_gene', 
  'TR_C_gene', 'TR_J_gene', 'TR_V_gene', 'TR_D_gene')

# output files
mofa_f      = sprintf('%s/mofa_%s_%s.hdf5', save_dir, run_tag, date_tag)
fgsea_pat   = sprintf('%s/mofa_fgsea_%s_%s_%s.txt', 
  save_dir, run_tag, '%s', date_tag)
interesting_f   = sprintf('%s/mofa_interesting_genes_%s_%s.xlsx', 
  save_dir, run_tag, date_tag)

# what to use to illustrate random effects concept?
example_cl  = 'Oligodendrocytes'
example_gs  = c("NHLH1_ENSG00000171786", "CASP7_ENSG00000165806", 
  "RELN_ENSG00000189056", "KLB_ENSG00000134962", "NRTN_ENSG00000171119", 
  "EVI5L_ENSG00000142459", "PWP2_ENSG00000241945", "GRID2_ENSG00000152208", 
  "MET_ENSG00000105976")

Load inputs

# load parameters
params      = params_f %>% readRDS

# load pseudobulk object
pb          = readRDS(params$pb_f) %>% .subset_pb(params$subset_spec) %>%
  subset_pb_celltypes(sel_cl)
  subsetting pb object
    restricting to samples that meet subset criteria
    updating factors to remove levels no longer observed
# check for any massive outliers
outliers_dt = calc_log_prop_outliers(pb, mad_cut = log_p_mad)
no samples have half or more of celltypes with very extreme (2 > MADs)
log proportions
ok_samples  = outliers_dt[ props_ok == TRUE ]$sample_id
pb          = pb[ , ok_samples ]

# load other useful things
labels_dt   = .load_labels_dt(labels_f, params$cluster_var)
Warning in FUN(X[[i]], ...): unable to translate '<U+00C4>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00D6>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00DC>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00E4>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00F6>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00FC>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00DF>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00C6>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00E6>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00D8>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00F8>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00C5>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00E5>' to native encoding
magma_dt    = .load_magma_dt(magma_f, pb)
tfs_dt      = .load_tfs_dt(tfs_f, pb)
lof_dt      = .load_lof_dt(lof_f, pb)
ok_genes    = get_biotypes_dt(gtf_f) %>%
  .[ gene_biotype %in% ok_types ] %>% 
  use_series('gene_id') %>% str_extract('^[^_]+')
assert_that( all(ok_genes %in% rowData(pb)$symbol) )
[1] TRUE
# load annotations
annots_dt   = .get_cols_dt(pb) %>% 
  .[, sample := sample_id ] %>% .[, group := 'single_group'] %>%
  .[, .(sample, sample_id, diagnosis, lesion_type, subject_id, subject_orig,
    sample_source, batch = seq_pool, age = age_at_death, age_at_death, age_scale, 
    years_w_ms, sex, pmi_cat, pmi_cat2, smoker )] %>%
  add_oligo_groups(olg_grps_f)

# get random effects
ranef_dt    = .load_ranef_dt(ranef_dt_f, labels_dt, pb)

# get results
res_dt      = muscat_f %>% fread %>%
  .load_muscat_results(labels_dt, params) %>%
  .[, .(cluster_id, gene_id, symbol, var_type, coef, test_var, 
    logCPM, mean_soup, padj = p_adj.soup, logFC)] %>%
  .[ !is.na(padj) ]

# get anova results
anova_dt    = .load_anova_dt(anova_f, res_dt) %>%
  .[ is.na(full), full := 1 ]

# get MDS outputs
mds_sep_dt  = mds_sep_f %>% fread
if (params$cluster_var == 'type_broad')
  mds_sep_dt[, cluster_id := factor(cluster_id, levels = broad_ord)]
# get random effects
sd_dt       = ranef_dt %>% calc_ranef_melt %>% calc_sd_dt
filter_dt   = calc_filter_dt(res_dt, sd_dt, pb, anova_dt, 
  max_p = max_p, min_sd = min_sd, min_fc = min_fc)
filtered_dt = filter_dt[ ( (ms_signif == 'signif') & (ms_effect == 'big') ) |
    ( (pt_signif == 'signif') & (pt_variab == 'variable')) ] %>%
  .[ cluster_id %in% sel_cl ] %>%
  .[, is_ms := ifelse(ms_effect == "big" & ms_signif == "signif", "ms", "not") ] %>%
  .[, is_pt := ifelse(pt_signif == "signif" & pt_variab == "variable", "pt", "not") ]

# check what we've got
filtered_dt[, .N, by = .(cluster_id, is_ms, is_pt)] %>%
  .[, total := sum( N ), by = cluster_id ] %>%
  dcast.data.table(cluster_id + total ~ is_ms + is_pt, fill = 0, value.var = "N")
          cluster_id total ms_not ms_pt not_pt
1:       OPCs / COPs    97     20     2     75
2:  Oligodendrocytes   507    259    16    232
3:        Astrocytes   794    559    29    206
4:         Microglia   667    255    48    364
5: Endothelial cells    86      2     0     84
6:         Pericytes    27      1     0     26
7:            Immune    27      4     0     23
n_cells_dt  = calc_n_cells_dt(pb_fine_f, annots_dt, sel_cl)
soup_dt     = get_soup_logcpms(soup_f, pb)
qc_stats    = calc_qc_stats_by_sample(qc_stats_f, qc_dir, qc_f, 
  meta_f, labels_f, labelled_f)

Processing / calculations

mofa_obj    = make_mofa_obj_samples(pb, filtered_dt, sel_cl, 
  lib_size_method = 'edger')
Removing 5430 rows with all zero counts
Removing 3463 rows with all zero counts
Removing 3766 rows with all zero counts
Removing 4578 rows with all zero counts
Removing 6797 rows with all zero counts
Removing 8883 rows with all zero counts
Removing 8781 rows with all zero counts
Creating MOFA object from a data.frame...
if (file.exists(mofa_f)) {
  model       = load_model(mofa_f)
} else {
  # set up
  data_opts   = get_default_data_options(mofa_obj)
  model_opts  = get_default_model_options(mofa_obj)
  train_opts  = get_default_training_options(mofa_obj)

  # specify how many factors
  model_opts$num_factors = n_factors

  # train mofa
  mofa_obj    = prepare_mofa(
    object = mofa_obj,
    data_options = data_opts,
    model_options = model_opts,
    training_options = train_opts
  )
  model       = run_mofa(mofa_obj, mofa_f)
}
Warning in .quality_control(object, verbose = verbose): Factor(s) 1 are strongly correlated with the total number of expressed features for at least one of your omics. Such factors appear when there are differences in the total 'levels' between your samples, *sometimes* because of poor normalisation in the preprocessing steps.
# add metadata
model       = add_metadata(model, annots_dt)

# put weights and scores in MS order
model       = put_model_in_ms_order(model)
var_exp_dt  = get_variance_explained(model, as.data.frame = TRUE) %>%
  as.data.table %>% 
  .[, .(
    view    = r2_per_factor.view %>% factor(levels = broad_short),
    factor  = r2_per_factor.factor,
    var_exp = r2_per_factor.value
  )]
to_plot_dt = var_exp_dt[ var_exp > min_var ] %>% .[order(factor, -var_exp)]

var_exp_no_endoperi = var_exp_dt[ !(view %in% c('endo', 'peri')) ]
# get weights, define expected files
ws_dt       = extract_weights(model, sd_dt)
fgsea_fs    = sapply(sel_ps, function(p) sprintf(fgsea_pat, p))

# if necessary, run FGSEA
if (all(file.exists(fgsea_fs))) {
  gsea_list   = lapply(fgsea_fs, fread)
} else {
  # do fgsea for these
  bpparam     = MulticoreParam(workers = n_cores, 
    progressbar = TRUE, tasks = 50)
  bpstart()
  gsea_list   = calc_mofa_fgsea(paths_list[ sel_ps ], ws_dt, fgsea_pat, fgsea_cut, bpparam)
  bpstop()
}

# restrict to interesting ones
gsea_main  = gsea_list %>% map( ~.x[ main_path == TRUE ]) %>% rbindlist
r2_dt       = calc_r2_for_factors(model, annots_dt, formula_str, random_var)
anova_dt    = calc_lrts(model, annots_dt, formula_str, random_var)

Analysis

muscat results vs SD

for (what in c('log10_padj', 'log2FC')) {
  cat('### ', what, '\n', sep = '')
  print(plot_muscat_vs_sd(res_dt, sd_dt, NULL, what = what))
  cat('\n\n')
}

log10_padj

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

log2FC

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Cytokine effects

cyto_gs   = unique(res_dt$gene_id) %>% str_subset('(^IL[0-9]+|^CCL|^CXCL|^IFN|^TGF|^TNF|^CSF)')
(plot_muscat_vs_sd_min(res_dt[ gene_id %in% cyto_gs ], sd_dt[ gene_id %in% cyto_gs ], 
  sel_cl, min_sd, max_p, do_labels = TRUE))

Ages vs duration of MS

(plot_age_duration(annots_dt))

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Data overview

(plot_data_overview(mofa_obj))

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Overlapping genes

cat('### All genes\n')

All genes

  suppressWarnings(print(plot_gene_overlap(model)))

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06
cat('\n\n')
for (sel_f in factors_names(model)) {
  cat('### Genes in ', sel_f, '\n', sep = '')
  suppressWarnings(print(plot_gene_overlap(model, sel_f = sel_f, w_cut = w_cut)))
  cat('\n\n')
}

Genes in Factor1

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Genes in Factor2

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Genes in Factor3

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Genes in Factor4

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Genes in Factor5

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Overlapping genes (proportions)

cat('### All genes\n')

All genes

  suppressWarnings(print(plot_gene_overlap(model, what = 'prop')))

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06
cat('\n\n')
for (sel_f in factors_names(model)) {
  cat('### Genes in ', sel_f, '\n', sep = '')
  suppressWarnings(print(plot_gene_overlap(model, what = 'prop', 
    sel_f = sel_f, w_cut = w_cut)))
  cat('\n\n')
}

Genes in Factor1

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Genes in Factor2

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Genes in Factor3

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Genes in Factor4

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Genes in Factor5

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor distributions

for (annot in c('lesion_type', 'diagnosis', 'sex', 'sample_source', 'smoker', 'oligo_grp')) {
  cat('### by ', annot, '\n', sep = '')
  print(plot_factors_univariate(model, annots_dt, pb, by = annot))
  cat('\n\n')
}

by lesion_type

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

by diagnosis

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

by sex

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

by sample_source

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

by smoker

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

by oligo_grp

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor distributions - pairwise

for (annot in c('subject_id', 'lesion_type', 'diagnosis', 'sex', 'sample_source', 'smoker', 'oligo_grp')) {
  cat('### by ', annot, '\n', sep = '')
  print(plot_factors_pairwise(model, annots_dt, pb, by = annot))
  cat('\n\n')
}

by subject_id

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

by lesion_type

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

by diagnosis

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

by sex

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

by sample_source

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

by smoker

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

by oligo_grp

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factors over MDS layouts

for (cl in broad_ord) {
  if (!(broad_short[[cl]] %in% views_names(model)))
    next
  cat('### ', cl, '\n', sep = '')
  print(plot_factors_over_mds_samples(model, mds_sep_dt, cl = cl))
  cat('\n\n')
}

OPCs / COPs

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Oligodendrocytes

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Astrocytes

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Microglia

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Endothelial cells

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Pericytes

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Immune

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Oligo groupings over MDS layouts

olg_types   = c("OPCs / COPs", "Oligodendrocytes")
(plot_oligo_grps_over_mds_samples(annots_dt, mds_sep_dt, olg_types))

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor distributions with patient annotations - few

for (v in c('score', 'score_scaled')) {
  cat('### ', v, '\n', sep = '')
  draw(plot_factors_heatmap(model, annots_dt, pb, what = 'few', plot_var = v))
  cat('\n\n')
}

score

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

score_scaled

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor distributions with patient annotations - all

for (v in c('score', 'score_scaled')) {
  cat('### ', v, '\n', sep = '')
  draw(plot_factors_heatmap(model, annots_dt, pb, what = 'all', plot_var = v), 
    merge_legend = TRUE)
  cat('\n\n')
}

score

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

score_scaled

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor distributions with patient annotations - with QC

draw(plot_factors_heatmap_w_qc(model, annots_dt, pb, qc_stats))

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factors vs QC metrics

(plot_factors_vs_qc(model, annots_dt, qc_stats))

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18

Coefficients of top genes (by factor)

for (f in factors_names(model)) {
  cat('### ', f, '\n', sep = '')
  draw(plot_top_weights_heatmap_by_factor(model, var_exp_dt, sel_f = f))
  cat('\n\n')
}

Factor1

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor2

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor3

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor4

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor5

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Expression of top genes per celltype

# iterate plots
for (i in seq.int(nrow(to_plot_dt))) {
  # descriptor of what plotted
  sel_v   = as.character(to_plot_dt[i]$view)
  sel_f   = to_plot_dt[i]$factor
  this_r2 = to_plot_dt[i]$var_exp

  # plot!
  cat('### ', sel_v, '-F', as.integer(sel_f), 
    ' (', round(this_r2, 0), '%)', '\n', sep = '')
  draw(plot_top_genes_expression(model, pb, annots_dt, 
      filter_dt, tfs_dt, to_plot_dt[i], 
      sel_f = sel_f, min_var = 5, min_w = 0.2, n_top = 40), 
    merge_legend = TRUE)
  cat('\n\n')
}

oligo-F1 (32%)

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

opc_cop-F1 (28%)

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

endo-F1 (24%)

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

micro-F1 (22%)

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

astro-F1 (19%)

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

immune-F1 (18%)

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

peri-F1 (12%)

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

peri-F2 (18%)

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

micro-F2 (18%)

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

astro-F2 (16%)

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

opc_cop-F2 (11%)

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

endo-F2 (7%)

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

oligo-F2 (7%)

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

oligo-F3 (14%)

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

opc_cop-F3 (9%)

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

micro-F3 (9%)

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

peri-F3 (7%)

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

astro-F3 (7%)

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

immune-F3 (6%)

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

astro-F4 (10%)

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

oligo-F4 (5%)

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

oligo-F5 (6%)

Version Author Date
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Expression of top genes across all factors per celltype

# iterate plots
for (sel_v in broad_short[sel_cl]) {
  cat('### ', sel_v, '\n', sep = '')
  draw(plot_top_genes_expression_all_factors(model, pb, annots_dt, filter_dt, 
    tfs_dt, var_exp_dt, sel_v = sel_v, n_top = 10, min_var), merge_legend = TRUE )
  cat('\n\n')
}

opc_cop

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

oligo

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

astro

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

micro

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

endo

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

peri

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

immune

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factors vs number of cells

for (f in factors_names(model) ) {
  cat('### ', f, '\n', sep = '')
  print(plot_mofa_vs_n_cells(model, n_cells_dt, sel_f = f))
  cat('\n\n')
}

Factor1

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor2

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor3

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor4

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor5

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factors vs top genes

for (f in factors_names(model)) {
  cat('### ', f, '\n', sep = '')
  print(plot_mofa_vs_logcpm(model, annots_dt, sel_f = f))
  cat('\n\n')
}

Factor1

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor2

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor3

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor4

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor5

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factors vs top genes - soup

for (f in factors_names(model) ) {
  cat('### ', f, '\n', sep = '')
  print(plot_mofa_vs_soup_logcpm(model, annots_dt, soup_dt, 
    sel_f = f, trans = 'linear'))
  cat('\n\n')
}

Factor1

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor2

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor3

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor4

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor5

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Distributions of factor weights

(plot_mofa_weights(model))

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor weights vs muscat results

for (what in c('log10_padj', 'log2FC')) {
  cat('### ', what, '\n', sep = '')
  print(plot_muscat_vs_mofa(model, filter_dt, what = what))
  cat('\n\n')
}

log10_padj

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

log2FC

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Correlations between factor weights - split by celltype

for (v in broad_short[sel_cl]) {
  cat('### ', v, '\n', sep = '')
  print(plot_factor_weight_corrs(model, v, by = 'type', how = 'bin'))
  cat('\n\n')
}

opc_cop

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

oligo

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

astro

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

micro

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

endo

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

peri

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

immune

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Correlations between factor weights - split by factor

for (f in factors_names(model) ) {
  cat('### ', f, '\n', sep = '')
  print(plot_factor_weight_corrs(model, f, by = 'factor', how = 'point'))
  cat('\n\n')
}

Factor1

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor2

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor3

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor4

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor5

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Variance explained

(plot_var_exp(var_exp_dt))

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

GSEA for factors

for (p in names(gsea_list)) {
  # restrict to relevant GO terms
  cat('### ', p, '\n', sep='')
  dt    = gsea_list[[p]]
  if (nrow(dt[ main_path == TRUE ]) == 0)
    next
  # plot
  print(plot_mofa_gsea_dotplot(dt, labels_dt, 
    fgsea_cut = fgsea_cut, n_total = 60))
  cat('\n\n')
}

go_bp

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

go_cc

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

go_mf

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

hallmark

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

kegg

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Outputs

Top filter genes

# merge filtered and weights
xls_dt    = calc_xls_dt(model, filtered_dt)

# save outputs
write_xlsx(list(mofa_weights = xls_dt), path = interesting_f)

Figures

Illustrative example

for (g in example_gs) {
  cat('### ', str_extract(g, '^[^_]+'), '\n', sep = '')
  suppressWarnings(print(plot_ranef_example(pb, example_cl, g)))
  cat('\n\n')
}

NHLH1

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

CASP7

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

RELN

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

KLB

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

NRTN

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

EVI5L

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

PWP2

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

GRID2

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

MET

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Selection of interesting genes

for (what in c('fc_vs_sd_all', 'fc_vs_sd_signif', 'ms_p_vs_lrt_p')) {
  cat("### ", what, "\n")
  print(plot_ms_vs_random(filter_dt, sel_cl, max_p, min_fc, min_sd, what = what))
  cat("\n\n")
}

fc_vs_sd_all

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

fc_vs_sd_signif

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

ms_p_vs_lrt_p

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

muscat results vs SD, MAGMA hits only

magma_hits  = magma_dt[ p_magma_adj < 0.1 ]$gene_id
(plot_muscat_vs_sd_min(res_dt[ gene_id %in% magma_hits ], sd_dt, 
  sel_cl, min_sd, max_p))

muscat results vs LoFs

(plot_muscat_and_sd_vs_lof(res_dt, sd_dt, lof_dt, sel_cl))

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Expression heatmaps

Some notes:

  • pca has both rows and columns ordered in a sensible data-driven way.
  • clustered has the rows clustered by hierarchical clustering, and the columns the same as pca.
  • three_per_patient is the same as clustered but only showing patients where we have >=3 samples.
  • by_lesion has the rows ordered by lesion type, and the columns ordered by MS logFC (hopefully this shows the horseshoe a bit).
  • FactorX has the rows ordered by each sample’s factor score, and the columns ordered by each gene’s factor weight; I also exclude genes with small weights for that factor.
  • is_shared on top of the heatmap indicates whether a gene is unique to the celltype, or was also selected for another celltype.
for (o in c("pca", "clustered", "three_per_patient", "by_lesion", factors_names(model))) {
  cat("### ", o, "\n")
  draw(plot_expression_heatmap_samples(pb, filtered_dt, annots_dt, sel_cl,
    model, ordering = o)
    , merge_legend = TRUE)
  cat("\n\n")
}

pca

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

clustered

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

three_per_patient

by_lesion

Warning: Unknown levels in `f`: GM

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor1

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor2

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor3

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor4

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor5

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Expression heatmap, narrower

for (o in c("clustered", "by_lesion")) {
  cat("### ", o, "\n")
  draw(plot_expression_heatmap_samples(pb, filtered_dt, annots_dt, sel_cl,
    model, ordering = o)
    , merge_legend = TRUE)
  cat("\n\n")
}

clustered

by_lesion

Warning: Unknown levels in `f`: GM

Version Author Date
91ab359 Will Macnair 2022-03-23

Version Author Date
91ab359 Will Macnair 2022-03-23

MOFA+ factors - diagnosis

(plot_factors_univariate(model, annots_dt, pb, by = 'diagnosis'))

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

MOFA+ factors - lesions

(plot_factors_univariate(model, annots_dt, pb, by = 'lesion_type'))

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor 1 vs Factor 2

for (what in c("diagnosis", "lesion_type", "subject_id")) {
  cat('### ', what, '\n', sep = '')
  print(plot_factors_pair(model, annots_dt, pb, 
    f_pair = c("Factor2", "Factor1"), by = what))
  cat('\n\n')
}

diagnosis

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

lesion_type

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

subject_id

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Interactions between factors and model components

(plot_factor_r2s(r2_dt, var_exp_dt))

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Does metadata explain factors?

(plot_factor_anovas(anova_dt))

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

GO terms for factors

print(plot_mofa_gsea_dotplot(gsea_list[['go_bp']], labels_dt, 
  fgsea_cut = fgsea_cut, n_total = 50))

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Top genes for Factor 1

draw( plot_top_genes_expression(model, pb, annots_dt, 
  filter_dt, tfs_dt, var_exp_no_endoperi, 
  sel_f = 'Factor1', min_var = 5, min_w = 0.2, n_top = 15, ok_genes = ok_genes),
  heatmap_legend_side = 'left', annotation_legend_side = 'left')

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Top genes for Factor 2

draw( plot_top_genes_expression(model, pb, annots_dt, 
  filter_dt, tfs_dt, var_exp_no_endoperi, 
  sel_f = 'Factor2', min_var = 5, min_w = 0.2, n_top = 15, ok_genes = ok_genes),
  heatmap_legend_side = 'left', annotation_legend_side = 'left')

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Top genes for Factor 3

draw( plot_top_genes_expression(model, pb, annots_dt, 
  filter_dt, tfs_dt, var_exp_no_endoperi, 
  sel_f = 'Factor3', min_var = 5, min_w = 0.2, n_top = 15, ok_genes = ok_genes),
  heatmap_legend_side = 'left', annotation_legend_side = 'left')

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Top genes for Factor 4

draw( plot_top_genes_expression(model, pb, annots_dt, 
  filter_dt, tfs_dt, var_exp_no_endoperi, 
  sel_f = 'Factor4', min_var = 5, min_w = 0.2, n_top = 15, ok_genes = ok_genes),
  heatmap_legend_side = 'left', annotation_legend_side = 'left')

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Top genes for Factor 5

draw( plot_top_genes_expression(model, pb, annots_dt, 
  filter_dt, tfs_dt, var_exp_no_endoperi, 
  sel_f = 'Factor5', min_var = 5, min_w = 0.2, n_top = 15, ok_genes = ok_genes),
  heatmap_legend_side = 'left', annotation_legend_side = 'left')

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Barplots of celltype proportions ordered by factors

conos_dt    = load_labelled_dt(labelled_f, labels_f)
types       = c('OPCs / COPs', 'Oligodendrocytes')
m           = "WM"
oligos_dt   = conos_dt[ type_broad %in% types & str_detect(sample_id, "WM") ] %>%
  .[, N_sample  := .N, by = sample_id] %>%
  .[, .N, by = .(sample_id, N_sample, type_broad, type_fine)] %>%
  .[, prop      := N / sum(N), by = .(sample_id, type_broad)] %>%
  .[, type_fine := fct_relevel(type_fine, 'OPC')]
for (sel_f in factors_names(model)) {
  cat('### ', sel_f, '\n', sep = '')
  print(plot_barplots_ordered_by_factors(oligos_dt, model, sel_f))
  cat('\n\n')
}

Factor1

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor2

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor3

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor4

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06

Factor5

Version Author Date
91ab359 Will Macnair 2022-03-23
7c17d96 Macnair 2022-03-18
74935aa wmacnair 2022-03-06
devtools::session_info()
- Session info ---------------------------------------------------------------
 setting  value
 version  R version 4.1.2 (2021-11-01)
 os       Red Hat Enterprise Linux 8.2 (Ootpa)
 system   x86_64, linux-gnu
 ui       X11
 language (EN)
 collate  en_US.UTF-8
 ctype    C
 tz       Europe/Amsterdam
 date     2022-03-24
 pandoc   2.5 @ /apps/rocs/pRED/2020.08/cascadelake/software/Pandoc/2.5/bin/ (via rmarkdown)

- Packages -------------------------------------------------------------------
 package              * version    date (UTC) lib source
 abind                  1.4-5      2016-07-21 [5] CRAN (R 4.1.2)
 ade4                   1.7-18     2021-09-16 [5] CRAN (R 4.1.2)
 ANCOMBC              * 1.4.0      2021-10-26 [3] Bioconductor
 annotate               1.72.0     2021-10-26 [3] Bioconductor
 AnnotationDbi          1.56.2     2021-11-09 [3] Bioconductor
 ape                    5.5        2021-04-25 [5] CRAN (R 4.1.2)
 assertthat           * 0.2.1      2019-03-21 [5] CRAN (R 4.1.2)
 backports              1.4.0      2021-11-23 [5] CRAN (R 4.1.2)
 basilisk               1.6.0      2021-10-26 [1] Bioconductor
 basilisk.utils         1.6.0      2021-10-26 [1] Bioconductor
 beachmat               2.10.0     2021-10-26 [3] Bioconductor
 beeswarm               0.4.0      2021-06-01 [3] CRAN (R 4.1.2)
 Biobase              * 2.54.0     2021-10-26 [3] Bioconductor
 BiocGenerics         * 0.40.0     2021-10-26 [3] Bioconductor
 BiocIO                 1.4.0      2021-10-26 [3] Bioconductor
 BiocManager            1.30.16    2021-06-15 [3] CRAN (R 4.1.2)
 BiocNeighbors          1.12.0     2021-10-26 [3] Bioconductor
 BiocParallel         * 1.28.3     2021-12-09 [1] Bioconductor
 BiocSingular           1.10.0     2021-10-26 [3] Bioconductor
 BiocStyle            * 2.22.0     2021-10-26 [3] Bioconductor
 biomformat             1.22.0     2021-10-26 [3] Bioconductor
 Biostrings             2.62.0     2021-10-26 [3] Bioconductor
 bit                    4.0.4      2020-08-04 [5] CRAN (R 4.1.2)
 bit64                  4.0.5      2020-08-30 [5] CRAN (R 4.1.2)
 bitops                 1.0-7      2021-04-24 [5] CRAN (R 4.1.2)
 blme                   1.0-5      2021-01-05 [3] CRAN (R 4.1.2)
 blob                   1.2.2      2021-07-23 [5] CRAN (R 4.1.2)
 boot                   1.3-28     2021-05-03 [5] CRAN (R 4.1.2)
 brew                   1.0-6      2011-04-13 [5] CRAN (R 4.1.2)
 broom                  0.7.10     2021-10-31 [5] CRAN (R 4.1.2)
 bslib                  0.3.1      2021-10-06 [5] CRAN (R 4.1.2)
 cachem                 1.0.6      2021-08-19 [5] CRAN (R 4.1.2)
 callr                  3.7.0      2021-04-20 [5] CRAN (R 4.1.2)
 caTools                1.18.2     2021-03-28 [5] CRAN (R 4.1.2)
 cellranger             1.1.0      2016-07-27 [5] CRAN (R 4.1.2)
 circlize             * 0.4.13     2021-06-09 [3] CRAN (R 4.1.2)
 cli                    3.2.0      2022-02-14 [1] CRAN (R 4.1.2)
 clue                   0.3-60     2021-10-11 [5] CRAN (R 4.1.2)
 cluster                2.1.2      2021-04-17 [5] CRAN (R 4.1.2)
 coda                   0.19-4     2020-09-30 [5] CRAN (R 4.1.2)
 codetools              0.2-18     2020-11-04 [5] CRAN (R 4.1.2)
 colorspace             2.0-3      2022-02-21 [1] CRAN (R 4.1.2)
 ComplexHeatmap       * 2.10.0     2021-10-26 [3] Bioconductor
 corrplot               0.92       2021-11-18 [3] CRAN (R 4.1.2)
 cowplot                1.1.1      2020-12-30 [5] CRAN (R 4.1.2)
 crayon                 1.5.0      2022-02-14 [1] CRAN (R 4.1.2)
 data.table           * 1.14.2     2021-09-27 [5] CRAN (R 4.1.2)
 DBI                    1.1.1      2021-01-15 [5] CRAN (R 4.1.2)
 dbplyr                 2.1.1      2021-04-06 [5] CRAN (R 4.1.2)
 DelayedArray           0.20.0     2021-10-26 [3] Bioconductor
 DelayedMatrixStats     1.16.0     2021-10-26 [3] Bioconductor
 deldir                 1.0-6      2021-10-23 [5] CRAN (R 4.1.2)
 dendsort               0.3.4      2021-04-20 [1] CRAN (R 4.1.2)
 desc                   1.4.0      2021-09-28 [5] CRAN (R 4.1.2)
 DESeq2                 1.34.0     2021-10-26 [3] Bioconductor
 devtools               2.4.3      2021-11-30 [5] CRAN (R 4.1.2)
 digest                 0.6.29     2021-12-01 [5] CRAN (R 4.1.2)
 dir.expiry             1.2.0      2021-10-26 [1] Bioconductor
 doParallel             1.0.16     2020-10-16 [5] CRAN (R 4.1.2)
 dplyr                * 1.0.7      2021-06-18 [5] CRAN (R 4.1.2)
 drat                   0.2.2      2021-12-02 [1] CRAN (R 4.1.2)
 edgeR                * 3.36.0     2021-10-26 [3] Bioconductor
 ellipsis               0.3.2      2021-04-29 [5] CRAN (R 4.1.2)
 emmeans                1.7.1-1    2021-11-29 [3] CRAN (R 4.1.2)
 estimability           1.3        2018-02-11 [3] CRAN (R 4.1.2)
 evaluate               0.15       2022-02-18 [1] CRAN (R 4.1.2)
 fansi                  1.0.2      2022-01-14 [1] CRAN (R 4.1.2)
 farver                 2.1.0      2021-02-28 [5] CRAN (R 4.1.2)
 fastmap                1.1.0      2021-01-25 [5] CRAN (R 4.1.2)
 fastmatch              1.1-3      2021-07-23 [3] CRAN (R 4.1.2)
 fgsea                * 1.20.0     2021-10-26 [3] Bioconductor
 filelock               1.0.2      2018-10-05 [3] CRAN (R 4.1.2)
 fitdistrplus           1.1-6      2021-09-28 [5] CRAN (R 4.1.2)
 forcats              * 0.5.1      2021-01-27 [5] CRAN (R 4.1.2)
 foreach                1.5.1      2020-10-15 [5] CRAN (R 4.1.2)
 fs                     1.5.1      2021-11-30 [5] CRAN (R 4.1.2)
 future               * 1.23.0     2021-10-31 [5] CRAN (R 4.1.2)
 future.apply           1.8.1      2021-08-10 [5] CRAN (R 4.1.2)
 genefilter             1.76.0     2021-10-26 [3] Bioconductor
 geneplotter            1.72.0     2021-10-26 [3] Bioconductor
 generics               0.1.1      2021-10-25 [5] CRAN (R 4.1.2)
 GenomeInfoDb         * 1.30.1     2022-01-30 [1] Bioconductor
 GenomeInfoDbData       1.2.7      2022-03-15 [3] Bioconductor
 GenomicAlignments      1.30.0     2021-10-26 [3] Bioconductor
 GenomicRanges        * 1.46.1     2021-11-18 [3] Bioconductor
 GetoptLong             1.0.5      2020-12-15 [3] CRAN (R 4.1.2)
 ggbeeswarm           * 0.6.0      2017-08-07 [3] CRAN (R 4.1.2)
 ggplot.multistats    * 1.0.0      2019-10-28 [1] CRAN (R 4.1.2)
 ggplot2              * 3.3.5      2021-06-25 [5] CRAN (R 4.1.2)
 ggrepel              * 0.9.1      2021-01-15 [5] CRAN (R 4.1.2)
 ggridges               0.5.3      2021-01-08 [5] CRAN (R 4.1.2)
 git2r                  0.29.0     2021-11-22 [5] CRAN (R 4.1.2)
 glmmTMB                1.1.2.3    2021-09-20 [3] CRAN (R 4.1.2)
 GlobalOptions          0.1.2      2020-06-10 [3] CRAN (R 4.1.2)
 globals                0.14.0     2020-11-22 [5] CRAN (R 4.1.2)
 glue                   1.6.2      2022-02-24 [1] CRAN (R 4.1.2)
 goftest                1.2-3      2021-10-07 [5] CRAN (R 4.1.2)
 gplots                 3.1.1      2020-11-28 [5] CRAN (R 4.1.2)
 gridExtra              2.3        2017-09-09 [5] CRAN (R 4.1.2)
 grr                    0.9.5      2016-08-26 [1] CRAN (R 4.1.2)
 gtable                 0.3.0      2019-03-25 [5] CRAN (R 4.1.2)
 gtools                 3.9.2      2021-06-06 [5] CRAN (R 4.1.2)
 haven                  2.4.3      2021-08-04 [5] CRAN (R 4.1.2)
 HDF5Array              1.22.1     2021-11-14 [3] Bioconductor
 hexbin                 1.28.2     2021-01-08 [5] CRAN (R 4.1.2)
 highr                  0.9        2021-04-16 [5] CRAN (R 4.1.2)
 hms                    1.1.1      2021-09-26 [5] CRAN (R 4.1.2)
 htmltools              0.5.2      2021-08-25 [5] CRAN (R 4.1.2)
 htmlwidgets            1.5.4      2021-09-08 [5] CRAN (R 4.1.2)
 httpuv                 1.6.3      2021-09-09 [5] CRAN (R 4.1.2)
 httr                   1.4.2      2020-07-20 [5] CRAN (R 4.1.2)
 ica                    1.0-2      2018-05-24 [5] CRAN (R 4.1.2)
 igraph               * 1.2.11     2022-01-04 [1] CRAN (R 4.1.2)
 insight                0.16.0     2022-02-17 [1] CRAN (R 4.1.2)
 IRanges              * 2.28.0     2021-10-26 [3] Bioconductor
 irlba                  2.3.5      2021-12-06 [5] CRAN (R 4.1.2)
 iterators              1.0.13     2020-10-15 [5] CRAN (R 4.1.2)
 janitor                2.1.0      2021-01-05 [2] CRAN (R 4.1.2)
 jquerylib              0.1.4      2021-04-26 [5] CRAN (R 4.1.2)
 jsonlite               1.8.0      2022-02-22 [1] CRAN (R 4.1.2)
 KEGGREST               1.34.0     2021-10-26 [3] Bioconductor
 KernSmooth             2.23-20    2021-05-03 [5] CRAN (R 4.1.2)
 knitr                  1.37       2021-12-16 [1] CRAN (R 4.1.2)
 labeling               0.4.2      2020-10-20 [5] CRAN (R 4.1.2)
 later                  1.3.0      2021-08-18 [5] CRAN (R 4.1.2)
 lattice                0.20-45    2021-09-22 [5] CRAN (R 4.1.2)
 lazyeval               0.2.2      2019-03-15 [5] CRAN (R 4.1.2)
 leiden                 0.3.9      2021-07-27 [5] CRAN (R 4.1.2)
 lifecycle              1.0.1      2021-09-24 [5] CRAN (R 4.1.2)
 limma                * 3.50.0     2021-10-26 [3] Bioconductor
 listenv                0.8.0      2019-12-05 [5] CRAN (R 4.1.2)
 lme4                   1.1-27.1   2021-06-22 [5] CRAN (R 4.1.2)
 lmerTest               3.1-3      2020-10-23 [3] CRAN (R 4.1.2)
 lmtest                 0.9-39     2021-11-07 [5] CRAN (R 4.1.2)
 locfit                 1.5-9.4    2020-03-25 [5] CRAN (R 4.1.2)
 lubridate              1.8.0      2021-10-07 [5] CRAN (R 4.1.2)
 magick                 2.7.3      2021-08-18 [2] CRAN (R 4.1.2)
 magrittr             * 2.0.2      2022-01-26 [1] CRAN (R 4.1.2)
 MASS                 * 7.3-54     2021-05-03 [5] CRAN (R 4.1.2)
 Matrix               * 1.3-4      2021-06-01 [5] CRAN (R 4.1.2)
 Matrix.utils         * 0.9.8      2020-02-26 [1] CRAN (R 4.1.2)
 MatrixGenerics       * 1.6.0      2021-10-26 [3] Bioconductor
 matrixStats          * 0.61.0     2021-09-17 [5] CRAN (R 4.1.2)
 memoise                2.0.1      2021-11-26 [5] CRAN (R 4.1.2)
 mgcv                   1.8-38     2021-10-06 [5] CRAN (R 4.1.2)
 microbiome             1.16.0     2021-10-26 [3] Bioconductor
 mime                   0.12       2021-09-28 [5] CRAN (R 4.1.2)
 miniUI                 0.1.1.1    2018-05-18 [5] CRAN (R 4.1.2)
 minqa                  1.2.4      2014-10-09 [5] CRAN (R 4.1.2)
 modelr                 0.1.8      2020-05-19 [5] CRAN (R 4.1.2)
 MOFA2                * 1.4.0      2021-10-26 [1] Bioconductor
 multcomp               1.4-17     2021-04-29 [5] CRAN (R 4.1.2)
 multtest               2.50.0     2021-10-26 [3] Bioconductor
 munsell                0.5.0      2018-06-12 [5] CRAN (R 4.1.2)
 muscat               * 1.8.0      2021-10-26 [3] Bioconductor
 mvtnorm                1.1-3      2021-10-08 [5] CRAN (R 4.1.2)
 N2R                    1.0.1      2022-01-18 [1] CRAN (R 4.1.2)
 nlme                   3.1-153    2021-09-07 [5] CRAN (R 4.1.2)
 nloptr                 1.2.2.3    2021-11-02 [5] CRAN (R 4.1.2)
 numDeriv               2016.8-1.1 2019-06-06 [5] CRAN (R 4.1.2)
 pagoda2              * 1.0.9      2022-03-02 [1] CRAN (R 4.1.2)
 parallelly             1.29.0     2021-11-21 [5] CRAN (R 4.1.2)
 patchwork            * 1.1.0.9000 2022-03-23 [1] Github (thomasp85/patchwork@79223d3)
 pbapply                1.5-0      2021-09-16 [5] CRAN (R 4.1.2)
 pbkrtest               0.5.1      2021-03-09 [5] CRAN (R 4.1.2)
 performance          * 0.8.0      2021-10-01 [1] CRAN (R 4.1.2)
 permute                0.9-5      2019-03-12 [3] CRAN (R 4.1.2)
 pheatmap               1.0.12     2019-01-04 [3] CRAN (R 4.1.2)
 phyloseq             * 1.38.0     2021-10-26 [3] Bioconductor
 pillar                 1.7.0      2022-02-01 [1] CRAN (R 4.1.2)
 pkgbuild               1.2.1      2021-11-30 [5] CRAN (R 4.1.2)
 pkgconfig              2.0.3      2019-09-22 [5] CRAN (R 4.1.2)
 pkgload                1.2.4      2021-11-30 [5] CRAN (R 4.1.2)
 plotly                 4.10.0     2021-10-09 [5] CRAN (R 4.1.2)
 plyr                   1.8.6      2020-03-03 [5] CRAN (R 4.1.2)
 png                    0.1-7      2013-12-03 [5] CRAN (R 4.1.2)
 polyclip               1.10-0     2019-03-14 [5] CRAN (R 4.1.2)
 prettyunits            1.1.1      2020-01-24 [5] CRAN (R 4.1.2)
 processx               3.5.2      2021-04-30 [5] CRAN (R 4.1.2)
 progress               1.2.2      2019-05-16 [5] CRAN (R 4.1.2)
 promises               1.2.0.1    2021-02-11 [5] CRAN (R 4.1.2)
 ps                     1.6.0      2021-02-28 [5] CRAN (R 4.1.2)
 purrr                * 0.3.4      2020-04-17 [5] CRAN (R 4.1.2)
 R.methodsS3            1.8.1      2020-08-26 [5] CRAN (R 4.1.2)
 R.oo                   1.24.0     2020-08-26 [5] CRAN (R 4.1.2)
 R.utils                2.11.0     2021-09-26 [5] CRAN (R 4.1.2)
 R6                     2.5.1      2021-08-19 [5] CRAN (R 4.1.2)
 RANN                   2.6.1      2019-01-08 [5] CRAN (R 4.1.2)
 rappdirs               0.3.3      2021-01-31 [5] CRAN (R 4.1.2)
 rbibutils              2.2.7      2021-12-07 [5] CRAN (R 4.1.2)
 RColorBrewer         * 1.1-2      2014-12-07 [5] CRAN (R 4.1.2)
 Rcpp                   1.0.8.3    2022-03-17 [1] CRAN (R 4.1.2)
 RcppAnnoy              0.0.19     2021-07-30 [5] CRAN (R 4.1.2)
 RCurl                  1.98-1.6   2022-02-08 [1] CRAN (R 4.1.2)
 Rdpack                 2.1.3      2021-12-08 [5] CRAN (R 4.1.2)
 readr                * 2.1.1      2021-11-30 [5] CRAN (R 4.1.2)
 readxl               * 1.3.1      2019-03-13 [5] CRAN (R 4.1.2)
 registry               0.5-1      2019-03-05 [5] CRAN (R 4.1.2)
 remotes                2.4.2      2021-11-30 [5] CRAN (R 4.1.2)
 reprex                 2.0.1      2021-08-05 [5] CRAN (R 4.1.2)
 reshape2             * 1.4.4      2020-04-09 [5] CRAN (R 4.1.2)
 restfulr               0.0.13     2017-08-06 [3] CRAN (R 4.1.2)
 reticulate           * 1.22       2021-09-17 [5] CRAN (R 4.1.2)
 rhdf5                  2.38.0     2021-10-26 [3] Bioconductor
 rhdf5filters           1.6.0      2021-10-26 [3] Bioconductor
 Rhdf5lib               1.16.0     2021-10-26 [3] Bioconductor
 rjson                  0.2.20     2018-06-08 [5] CRAN (R 4.1.2)
 rlang                  1.0.2      2022-03-04 [1] CRAN (R 4.1.2)
 rmarkdown            * 2.13       2022-03-10 [1] CRAN (R 4.1.2)
 RMTstat                0.3        2014-11-01 [1] CRAN (R 4.1.2)
 ROCR                   1.0-11     2020-05-02 [5] CRAN (R 4.1.2)
 Rook                   1.1-1      2014-10-20 [1] CRAN (R 4.1.2)
 rpart                  4.1-15     2019-04-12 [5] CRAN (R 4.1.2)
 rprojroot              2.0.2      2020-11-15 [5] CRAN (R 4.1.2)
 Rsamtools              2.10.0     2021-10-26 [3] Bioconductor
 RSQLite                2.2.9      2021-12-06 [5] CRAN (R 4.1.2)
 rstudioapi             0.13       2020-11-12 [5] CRAN (R 4.1.2)
 rsvd                   1.0.5      2021-04-16 [5] CRAN (R 4.1.2)
 rtracklayer          * 1.54.0     2021-10-26 [3] Bioconductor
 Rtsne                  0.15       2018-11-10 [5] CRAN (R 4.1.2)
 rvest                  1.0.2      2021-10-16 [5] CRAN (R 4.1.2)
 S4Vectors            * 0.32.3     2021-11-21 [3] Bioconductor
 sandwich               3.0-1      2021-05-18 [5] CRAN (R 4.1.2)
 sass                   0.4.0      2021-05-12 [5] CRAN (R 4.1.2)
 ScaledMatrix           1.2.0      2021-10-26 [3] Bioconductor
 scales               * 1.1.1      2020-05-11 [5] CRAN (R 4.1.2)
 scater               * 1.22.0     2021-10-26 [3] Bioconductor
 scattermore            0.7        2020-11-24 [5] CRAN (R 4.1.2)
 sccore                 1.0.1      2021-12-12 [1] CRAN (R 4.1.2)
 sctransform            0.3.2      2020-12-16 [5] CRAN (R 4.1.2)
 scuttle              * 1.4.0      2021-10-26 [3] Bioconductor
 seriation            * 1.3.1      2021-10-16 [3] CRAN (R 4.1.2)
 sessioninfo            1.2.2      2021-12-06 [5] CRAN (R 4.1.2)
 Seurat               * 4.0.5      2021-10-17 [5] CRAN (R 4.1.2)
 SeuratObject         * 4.0.4      2021-11-23 [5] CRAN (R 4.1.2)
 shape                  1.4.6      2021-05-19 [3] CRAN (R 4.1.2)
 shiny                  1.7.1      2021-10-02 [5] CRAN (R 4.1.2)
 SingleCellExperiment * 1.16.0     2021-10-26 [3] Bioconductor
 snakecase              0.11.0     2019-05-25 [2] CRAN (R 4.1.2)
 sparseMatrixStats      1.6.0      2021-10-26 [3] Bioconductor
 spatstat.core          2.3-2      2021-11-26 [5] CRAN (R 4.1.2)
 spatstat.data          2.1-0      2021-03-21 [5] CRAN (R 4.1.2)
 spatstat.geom          2.3-0      2021-10-09 [5] CRAN (R 4.1.2)
 spatstat.sparse        2.0-0      2021-03-16 [5] CRAN (R 4.1.2)
 spatstat.utils         2.2-0      2021-06-14 [5] CRAN (R 4.1.2)
 stringi                1.7.6      2021-11-29 [5] CRAN (R 4.1.2)
 stringr              * 1.4.0      2019-02-10 [5] CRAN (R 4.1.2)
 SummarizedExperiment * 1.24.0     2021-10-26 [3] Bioconductor
 survival               3.2-13     2021-08-24 [5] CRAN (R 4.1.2)
 tensor                 1.5        2012-05-05 [5] CRAN (R 4.1.2)
 testthat               3.1.1      2021-12-03 [5] CRAN (R 4.1.2)
 TH.data                1.1-0      2021-09-27 [5] CRAN (R 4.1.2)
 tibble               * 3.1.6      2021-11-07 [5] CRAN (R 4.1.2)
 tictoc               * 1.0.1      2021-04-19 [1] CRAN (R 4.1.2)
 tidyr                * 1.1.4      2021-09-27 [5] CRAN (R 4.1.2)
 tidyselect             1.1.1      2021-04-30 [5] CRAN (R 4.1.2)
 tidyverse            * 1.3.1      2021-04-15 [5] CRAN (R 4.1.2)
 TMB                    1.7.22     2021-09-28 [3] CRAN (R 4.1.2)
 triebeard              0.3.0      2016-08-04 [2] CRAN (R 4.1.2)
 TSP                    1.1-11     2021-10-06 [3] CRAN (R 4.1.2)
 tzdb                   0.2.0      2021-10-27 [5] CRAN (R 4.1.2)
 UpSetR               * 1.4.0      2019-05-22 [1] CRAN (R 4.1.2)
 urltools               1.7.3      2019-04-14 [2] CRAN (R 4.1.2)
 usethis                2.1.3      2021-10-27 [5] CRAN (R 4.1.2)
 utf8                   1.2.2      2021-07-24 [5] CRAN (R 4.1.2)
 uwot                   0.1.11     2021-12-02 [5] CRAN (R 4.1.2)
 variancePartition      1.24.0     2021-10-26 [3] Bioconductor
 vctrs                  0.3.8      2021-04-29 [5] CRAN (R 4.1.2)
 vegan                  2.5-7      2020-11-28 [3] CRAN (R 4.1.2)
 vipor                  0.4.5      2017-03-22 [3] CRAN (R 4.1.2)
 viridis              * 0.6.2      2021-10-13 [5] CRAN (R 4.1.2)
 viridisLite          * 0.4.0      2021-04-13 [5] CRAN (R 4.1.2)
 whisker                0.4        2019-08-28 [5] CRAN (R 4.1.2)
 withr                  2.5.0      2022-03-03 [1] CRAN (R 4.1.2)
 workflowr              1.7.0      2021-12-21 [1] CRAN (R 4.1.2)
 writexl              * 1.4.0      2021-04-20 [1] CRAN (R 4.1.2)
 xfun                   0.30       2022-03-02 [1] CRAN (R 4.1.2)
 XML                    3.99-0.8   2021-09-17 [5] CRAN (R 4.1.2)
 xml2                   1.3.3      2021-11-30 [5] CRAN (R 4.1.2)
 xtable                 1.8-4      2019-04-21 [5] CRAN (R 4.1.2)
 XVector                0.34.0     2021-10-26 [3] Bioconductor
 yaml                   2.3.5      2022-02-21 [1] CRAN (R 4.1.2)
 zlibbioc               1.40.0     2021-10-26 [3] Bioconductor
 zoo                    1.8-9      2021-03-09 [5] CRAN (R 4.1.2)

 [1] /gpfs/homefs/global/home/macnairw/R/x86_64-pc-linux-gnu-library/4.1.2-foss
 [2] /apps/rocs/2020.08/cascadelake/software/R-Roche-bundle/2021.12-foss-2020a-R-4.1.2
 [3] /apps/rocs/2020.08/cascadelake/software/R-bundle-Bioconductor/3.14-foss-2020a-R-4.1.2
 [4] /apps/rocs/2020.08/cascadelake/software/ncdf4/1.18-foss-2020a-R-4.1.2
 [5] /apps/rocs/2020.08/cascadelake/software/R/4.1.2-foss-2020a/lib64/R/library

------------------------------------------------------------------------------

sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux 8.2 (Ootpa)

Matrix products: default
BLAS/LAPACK: /apps/rocs/2020.08/cascadelake/software/OpenBLAS/0.3.9-GCC-9.3.0/lib/libopenblas_skylakexp-r0.3.9.so

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

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

other attached packages:
 [1] MOFA2_1.4.0                 rmarkdown_2.13             
 [3] tictoc_1.0.1                performance_0.8.0          
 [5] edgeR_3.36.0                limma_3.50.0               
 [7] reshape2_1.4.4              scater_1.22.0              
 [9] scuttle_1.4.0               Matrix.utils_0.9.8         
[11] UpSetR_1.4.0                muscat_1.8.0               
[13] dplyr_1.0.7                 readr_2.1.1                
[15] tidyr_1.1.4                 tibble_3.1.6               
[17] tidyverse_1.3.1             rtracklayer_1.54.0         
[19] ggbeeswarm_0.6.0            ggrepel_0.9.1              
[21] MASS_7.3-54                 phyloseq_1.38.0            
[23] ANCOMBC_1.4.0               patchwork_1.1.0.9000       
[25] writexl_1.4.0               reticulate_1.22            
[27] fgsea_1.20.0                BiocParallel_1.28.3        
[29] ggplot.multistats_1.0.0     seriation_1.3.1            
[31] ComplexHeatmap_2.10.0       pagoda2_1.0.9              
[33] igraph_1.2.11               SeuratObject_4.0.4         
[35] Seurat_4.0.5                future_1.23.0              
[37] Matrix_1.3-4                SingleCellExperiment_1.16.0
[39] SummarizedExperiment_1.24.0 Biobase_2.54.0             
[41] GenomicRanges_1.46.1        GenomeInfoDb_1.30.1        
[43] IRanges_2.28.0              S4Vectors_0.32.3           
[45] BiocGenerics_0.40.0         MatrixGenerics_1.6.0       
[47] matrixStats_0.61.0          purrr_0.3.4                
[49] readxl_1.3.1                forcats_0.5.1              
[51] ggplot2_3.3.5               scales_1.1.1               
[53] viridis_0.6.2               viridisLite_0.4.0          
[55] assertthat_0.2.1            stringr_1.4.0              
[57] data.table_1.14.2           magrittr_2.0.2             
[59] circlize_0.4.13             RColorBrewer_1.1-2         
[61] BiocStyle_2.22.0           

loaded via a namespace (and not attached):
  [1] rsvd_1.0.5                ica_1.0-2                
  [3] ps_1.6.0                  Rsamtools_2.10.0         
  [5] foreach_1.5.1             lmtest_0.9-39            
  [7] rprojroot_2.0.2           crayon_1.5.0             
  [9] spatstat.core_2.3-2       rbibutils_2.2.7          
 [11] rhdf5filters_1.6.0        nlme_3.1-153             
 [13] backports_1.4.0           reprex_2.0.1             
 [15] basilisk_1.6.0            rlang_1.0.2              
 [17] XVector_0.34.0            ROCR_1.0-11              
 [19] microbiome_1.16.0         irlba_2.3.5              
 [21] callr_3.7.0               nloptr_1.2.2.3           
 [23] filelock_1.0.2            rjson_0.2.20             
 [25] bit64_4.0.5               glue_1.6.2               
 [27] pheatmap_1.0.12           sctransform_0.3.2        
 [29] processx_3.5.2            pbkrtest_0.5.1           
 [31] parallel_4.1.2            vipor_0.4.5              
 [33] spatstat.sparse_2.0-0     AnnotationDbi_1.56.2     
 [35] spatstat.geom_2.3-0       haven_2.4.3              
 [37] tidyselect_1.1.1          usethis_2.1.3            
 [39] fitdistrplus_1.1-6        variancePartition_1.24.0 
 [41] XML_3.99-0.8              zoo_1.8-9                
 [43] GenomicAlignments_1.30.0  xtable_1.8-4             
 [45] evaluate_0.15             Rdpack_2.1.3             
 [47] cli_3.2.0                 zlibbioc_1.40.0          
 [49] rstudioapi_0.13           miniUI_0.1.1.1           
 [51] whisker_0.4               bslib_0.3.1              
 [53] rpart_4.1-15              fastmatch_1.1-3          
 [55] shiny_1.7.1               BiocSingular_1.10.0      
 [57] xfun_0.30                 clue_0.3-60              
 [59] pkgbuild_1.2.1            multtest_2.50.0          
 [61] cluster_2.1.2             caTools_1.18.2           
 [63] TSP_1.1-11                biomformat_1.22.0        
 [65] KEGGREST_1.34.0           ape_5.5                  
 [67] listenv_0.8.0             Biostrings_2.62.0        
 [69] png_0.1-7                 permute_0.9-5            
 [71] withr_2.5.0               bitops_1.0-7             
 [73] plyr_1.8.6                cellranger_1.1.0         
 [75] coda_0.19-4               pillar_1.7.0             
 [77] gplots_3.1.1              GlobalOptions_0.1.2      
 [79] cachem_1.0.6              multcomp_1.4-17          
 [81] fs_1.5.1                  GetoptLong_1.0.5         
 [83] DelayedMatrixStats_1.16.0 vctrs_0.3.8              
 [85] ellipsis_0.3.2            generics_0.1.1           
 [87] devtools_2.4.3            urltools_1.7.3           
 [89] tools_4.1.2               beeswarm_0.4.0           
 [91] munsell_0.5.0             emmeans_1.7.1-1          
 [93] DelayedArray_0.20.0       pkgload_1.2.4            
 [95] fastmap_1.1.0             compiler_4.1.2           
 [97] abind_1.4-5               httpuv_1.6.3             
 [99] sessioninfo_1.2.2         plotly_4.10.0            
[101] GenomeInfoDbData_1.2.7    gridExtra_2.3            
[103] glmmTMB_1.1.2.3           workflowr_1.7.0          
[105] dir.expiry_1.2.0          lattice_0.20-45          
[107] deldir_1.0-6              utf8_1.2.2               
[109] later_1.3.0               jsonlite_1.8.0           
[111] ScaledMatrix_1.2.0        dendsort_0.3.4           
[113] sparseMatrixStats_1.6.0   pbapply_1.5-0            
[115] estimability_1.3          genefilter_1.76.0        
[117] lazyeval_0.2.2            promises_1.2.0.1         
[119] doParallel_1.0.16         R.utils_2.11.0           
[121] goftest_1.2-3             spatstat.utils_2.2-0     
[123] brew_1.0-6                sandwich_3.0-1           
[125] cowplot_1.1.1             blme_1.0-5               
[127] Rtsne_0.15                uwot_0.1.11              
[129] HDF5Array_1.22.1          Rook_1.1-1               
[131] survival_3.2-13           numDeriv_2016.8-1.1      
[133] yaml_2.3.5                htmltools_0.5.2          
[135] memoise_2.0.1             BiocIO_1.4.0             
[137] locfit_1.5-9.4            digest_0.6.29            
[139] mime_0.12                 rappdirs_0.3.3           
[141] registry_0.5-1            N2R_1.0.1                
[143] RSQLite_2.2.9             future.apply_1.8.1       
[145] remotes_2.4.2             blob_1.2.2               
[147] vegan_2.5-7               R.oo_1.24.0              
[149] drat_0.2.2                labeling_0.4.2           
[151] splines_4.1.2             Rhdf5lib_1.16.0          
[153] RCurl_1.98-1.6            broom_0.7.10             
[155] hms_1.1.1                 modelr_0.1.8             
[157] rhdf5_2.38.0              colorspace_2.0-3         
[159] BiocManager_1.30.16       shape_1.4.6              
[161] sass_0.4.0                Rcpp_1.0.8.3             
[163] RANN_2.6.1                mvtnorm_1.1-3            
[165] fansi_1.0.2               tzdb_0.2.0               
[167] parallelly_1.29.0         R6_2.5.1                 
[169] ggridges_0.5.3            lifecycle_1.0.1          
[171] minqa_1.2.4               testthat_3.1.1           
[173] leiden_0.3.9              jquerylib_0.1.4          
[175] snakecase_0.11.0          desc_1.4.0               
[177] RcppAnnoy_0.0.19          TH.data_1.1-0            
[179] iterators_1.0.13          TMB_1.7.22               
[181] htmlwidgets_1.5.4         beachmat_2.10.0          
[183] polyclip_1.10-0           triebeard_0.3.0          
[185] RMTstat_0.3               rvest_1.0.2              
[187] mgcv_1.8-38               globals_0.14.0           
[189] insight_0.16.0            codetools_0.2-18         
[191] lubridate_1.8.0           gtools_3.9.2             
[193] prettyunits_1.1.1         dbplyr_2.1.1             
[195] basilisk.utils_1.6.0      R.methodsS3_1.8.1        
[197] gtable_0.3.0              DBI_1.1.1                
[199] git2r_0.29.0              tensor_1.5               
[201] httr_1.4.2                highr_0.9                
[203] KernSmooth_2.23-20        stringi_1.7.6            
[205] progress_1.2.2            farver_2.1.0             
[207] annotate_1.72.0           hexbin_1.28.2            
[209] magick_2.7.3              xml2_1.3.3               
[211] sccore_1.0.1              grr_0.9.5                
[213] boot_1.3-28               BiocNeighbors_1.12.0     
[215] lme4_1.1-27.1             restfulr_0.0.13          
[217] ade4_1.7-18               geneplotter_1.72.0       
[219] scattermore_0.7           DESeq2_1.34.0            
[221] bit_4.0.4                 spatstat.data_2.1-0      
[223] janitor_2.1.0             pkgconfig_2.0.3          
[225] lmerTest_3.1-3            corrplot_0.92            
[227] knitr_1.37