Last updated: 2025-02-07

Checks: 6 1

Knit directory: paed-airway-allTissues/

This reproducible R Markdown analysis was created with workflowr (version 1.7.1). 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 is untracked by Git. 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.

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(20230811) 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 9fe8c18. 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:    .Rproj.user/
    Ignored:    analysis/.DS_Store
    Ignored:    data/.DS_Store
    Ignored:    data/RDS/
    Ignored:    output/.DS_Store
    Ignored:    output/CSV/.DS_Store
    Ignored:    output/G000231_Neeland_batch1/
    Ignored:    output/G000231_Neeland_batch2_1/
    Ignored:    output/G000231_Neeland_batch2_2/
    Ignored:    output/G000231_Neeland_batch3/
    Ignored:    output/G000231_Neeland_batch4/
    Ignored:    output/G000231_Neeland_batch5/
    Ignored:    output/G000231_Neeland_batch9_1/
    Ignored:    output/RDS/
    Ignored:    output/plots/

Untracked files:
    Untracked:  analysis/03_Batch_Integration.Rmd
    Untracked:  analysis/Age_proportions.Rmd
    Untracked:  analysis/Age_proportions_AllBatches.Rmd
    Untracked:  analysis/All_Batches_QCExploratory_v2.Rmd
    Untracked:  analysis/All_metadata.Rmd
    Untracked:  analysis/Annotation_BAL.Rmd
    Untracked:  analysis/Annotation_Bronchial_brushings.Rmd
    Untracked:  analysis/Annotation_Nasal_brushings.Rmd
    Untracked:  analysis/BatchCorrection_Adenoids.Rmd
    Untracked:  analysis/BatchCorrection_Nasal_brushings.Rmd
    Untracked:  analysis/BatchCorrection_Tonsils.Rmd
    Untracked:  analysis/Batch_Integration_&_Downstream_analysis.Rmd
    Untracked:  analysis/Batch_correction_&_Downstream.Rmd
    Untracked:  analysis/Cell_cycle_regression.Rmd
    Untracked:  analysis/Clustering_Tonsils_v2.Rmd
    Untracked:  analysis/DGE_analysis_George.Rmd
    Untracked:  analysis/Master_metadata.Rmd
    Untracked:  analysis/Pediatric_Vs_Adult_Atlases.Rmd
    Untracked:  analysis/Preprocessing_Batch1_Nasal_brushings.Rmd
    Untracked:  analysis/Preprocessing_Batch2_Tonsils.Rmd
    Untracked:  analysis/Preprocessing_Batch3_Adenoids.Rmd
    Untracked:  analysis/Preprocessing_Batch4_Bronchial_brushings.Rmd
    Untracked:  analysis/Preprocessing_Batch5_Nasal_brushings.Rmd
    Untracked:  analysis/Preprocessing_Batch6_BAL.Rmd
    Untracked:  analysis/Preprocessing_Batch7_Bronchial_brushings.Rmd
    Untracked:  analysis/Preprocessing_Batch8_Adenoids.Rmd
    Untracked:  analysis/Preprocessing_Batch9_Tonsils.Rmd
    Untracked:  analysis/TonsilsVsAdenoids.Rmd
    Untracked:  analysis/cell_cycle_regression.R
    Untracked:  analysis/testing_age_all.Rmd
    Untracked:  code/pseudobulk_analysis.R
    Untracked:  data/Cell_labels_Gunjan_v2/
    Untracked:  data/Cell_labels_Mel/
    Untracked:  data/Cell_labels_Mel_v2/
    Untracked:  data/Cell_labels_Mel_v3/
    Untracked:  data/Cell_labels_modified_Gunjan/
    Untracked:  data/Gene_sets/
    Untracked:  data/Hs.c2.cp.reactome.v7.1.entrez.rds
    Untracked:  data/Raw_feature_bc_matrix/
    Untracked:  data/cell_labels_Mel_v4_Dec2024/
    Untracked:  data/celltypes_Mel_GD_v3.xlsx
    Untracked:  data/celltypes_Mel_GD_v4_no_dups.xlsx
    Untracked:  data/celltypes_Mel_modified.xlsx
    Untracked:  data/celltypes_Mel_v2.csv
    Untracked:  data/celltypes_Mel_v2.xlsx
    Untracked:  data/celltypes_Mel_v2_MN.xlsx
    Untracked:  data/celltypes_for_mel_MN.xlsx
    Untracked:  data/col_palette.xlsx
    Untracked:  data/earlyAIR_sample_sheets_combined.xlsx
    Untracked:  figure/DGE_Tonsils_CD8.Rmd/
    Untracked:  output/CSV/All_tissues.propeller.xlsx
    Untracked:  output/CSV/Bronchial_brushings/
    Untracked:  output/CSV/Bronchial_brushings_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/
    Untracked:  output/CSV/G000231_Neeland_Adenoids.propeller.xlsx
    Untracked:  output/CSV/G000231_Neeland_Bronchial_brushings.propeller.xlsx
    Untracked:  output/CSV/G000231_Neeland_Nasal_brushings.propeller.xlsx
    Untracked:  output/CSV/G000231_Neeland_Tonsils.propeller.xlsx
    Untracked:  output/CSV/Nasal_brushings/
    Untracked:  output/DGE/Adenoids_B_memory/
    Untracked:  output/DGE/Adenoids_CD4/
    Untracked:  output/DGE/Adenoids_CD8/
    Untracked:  output/DGE/Adenoids_Cycling_GCB/
    Untracked:  output/DGE/Adenoids_IFN/
    Untracked:  output/DGE/Tonsil_Atlas_CD4/
    Untracked:  output/DGE/Tonsils/DGE_Age_summary_Tonsils.xlsx
    Untracked:  output/DGE/Tonsils/Tonsils_Naïve B cells/
    Untracked:  output/DGE/Tonsils/~$DGE_Age_summary_Tonsils.xlsx
    Untracked:  output/DGE/Tonsils_CD4/
    Untracked:  output/DGE/Tonsils_CD8/
    Untracked:  output/DGE/Tonsils_IFN/
    Untracked:  test_col.csv
    Untracked:  test_col.txt
    Untracked:  test_col.xlsx

Unstaged changes:
    Deleted:    02_QC_exploratoryPlots.Rmd
    Deleted:    02_QC_exploratoryPlots.html
    Modified:   analysis/00_AllBatches_overview.Rmd
    Modified:   analysis/01_QC_emptyDrops.Rmd
    Modified:   analysis/02_QC_exploratoryPlots.Rmd
    Modified:   analysis/Adenoids.Rmd
    Modified:   analysis/Adenoids_v2.Rmd
    Modified:   analysis/Age_modeling.Rmd
    Modified:   analysis/AllBatches_QCExploratory.Rmd
    Modified:   analysis/BAL.Rmd
    Modified:   analysis/BAL_v2.Rmd
    Modified:   analysis/Bronchial_brushings.Rmd
    Modified:   analysis/Bronchial_brushings_v2.Rmd
    Modified:   analysis/Nasal_brushings.Rmd
    Modified:   analysis/Nasal_brushings_v2.Rmd
    Modified:   analysis/Subclustering_Adenoids.Rmd
    Modified:   analysis/Subclustering_BAL.Rmd
    Modified:   analysis/Subclustering_Bronchial_brushings.Rmd
    Modified:   analysis/Subclustering_Nasal_brushings.Rmd
    Modified:   analysis/Subclustering_Tonsils.Rmd
    Modified:   analysis/Tonsils.Rmd
    Modified:   analysis/Tonsils_v2.Rmd
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/REACTOME-cluster-limma-c0.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/REACTOME-cluster-limma-c1.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/REACTOME-cluster-limma-c10.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/REACTOME-cluster-limma-c11.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/REACTOME-cluster-limma-c12.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/REACTOME-cluster-limma-c13.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/REACTOME-cluster-limma-c14.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/REACTOME-cluster-limma-c15.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/REACTOME-cluster-limma-c16.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/REACTOME-cluster-limma-c17.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/REACTOME-cluster-limma-c2.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/REACTOME-cluster-limma-c3.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/REACTOME-cluster-limma-c4.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/REACTOME-cluster-limma-c5.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/REACTOME-cluster-limma-c6.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/REACTOME-cluster-limma-c7.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/REACTOME-cluster-limma-c8.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/REACTOME-cluster-limma-c9.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/up-cluster-limma-c0.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/up-cluster-limma-c1.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/up-cluster-limma-c10.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/up-cluster-limma-c11.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/up-cluster-limma-c12.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/up-cluster-limma-c13.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/up-cluster-limma-c14.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/up-cluster-limma-c15.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/up-cluster-limma-c16.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/up-cluster-limma-c17.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/up-cluster-limma-c2.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/up-cluster-limma-c3.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/up-cluster-limma-c4.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/up-cluster-limma-c5.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/up-cluster-limma-c6.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/up-cluster-limma-c7.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/up-cluster-limma-c8.csv
    Modified:   output/CSV/BAL_Marker_gene_clusters.limmaTrendRNA_snn_res.0.4/up-cluster-limma-c9.csv

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.


There are no past versions. Publish this analysis with wflow_publish() to start tracking its development.


suppressPackageStartupMessages({
  library(here)
  library(glue)
  library(patchwork)
  library(Seurat)
  library(dplyr)
  library(tidyverse)
  library(gridExtra)
  library(paletteer)
  library(viridis)
  library(tidyverse)
  library(scran)
  library(scater)
  library(ggridges)
  library(speckle)
  library(edgeR)
  library(limma)
  library(knitr)
  library(BiocStyle)
  library(org.Hs.eg.db)
  library(Glimma)
})

Make pseudobulked object

data_path <- here("output/RDS/AllBatches_Annotation_SEUs_v2/")
tissues <- c("Nasal_brushings", "Tonsils", "Adenoids", "Bronchial_brushings", "BAL") #Choose from this list
tissue <- "Tonsils"
seu <- readRDS(paste0(data_path, "G000231_Neeland_", tissue, ".annotated_clusters.SEU.rds"))
seu <- JoinLayers(seu)

Convert from Seurat to SingleCellExperiment object

sce <- SingleCellExperiment(list(counts = seu@assays$RNA@layers$counts),
                                                  colData = seu@meta.data)
rownames(sce) <- rownames(seu)

What cell populations are present?

table(sce$cell_labels_v2)

                    CD4 effector                          CD4 TCM 
                            2944                             3115 
                         CD4 TFH                           CD4 TN 
                           13486                            10211 
                        CD4 Treg                     CD4 Treg-eff 
                            2035                             3248 
                          CD8 TF                           CD8 TN 
                            4666                             4221 
                     Cycling GCB                        Cycling T 
                            4243                              536 
               Double negative T                 DZ early  Sphase 
                            1268                             5716 
                     DZ G2Mphase                           DZ GCB 
                            9872                             7913 
                  DZ late Sphase            DZtoLZ GCB transition 
                            3909                             8341 
          Early GC-committed NBC                        Early MBC 
                            5260                             8234 
              Early PC precursor                 Epithelial cells 
                            1354                              392 
      Follicular dendritic cells                    Gamma delta T 
                            1688                             1657 
GC-commited metabolic activation                          GCB-IFN 
                            1693                              324 
                      MAIT cells                       Mast cells 
                             511                               66 
                  Memory B cells            Monocytes/macrophages 
                           21730                             3004 
                Naïve B cell-IFN                    Naïve B cells 
                            7343                            38686 
         Naïve B cells activated                      Neutrophils 
                            6632                              552 
                        NK cells                   Plasma B cells 
                             876                             9121 
                Plasmacytoid DCs                      Pre-BCRi II 
                             429                             2743 
                     Pre-T cells                            T-IFN 
                              93                             1917 
                       TFH-LZ-GC 
                            8048 
# Count cells per cell type in each batch
celltype_counts <- table(sce$cell_labels_v2, sce$batch_name)

# Filter cell types that have at least 500 cells in both batches
valid_celltypes <- rownames(celltype_counts)[rowMins(as.matrix(celltype_counts)) >= 500]

celltypes_list <- intersect(unique(sce$cell_labels_v2), valid_celltypes)


summary_list <- list()
summary_list1 <- list()

for (celltype in celltypes_list) {
  cat("Processing:", celltype, "\n")
  
  pb <- aggregateAcrossCells(sce[, sce$cell_labels_v2 == celltype], 
                             id = colData(sce[, sce$cell_labels_v2 == celltype])[, "sample_id"])

  pb <- pb[, pb$ncells >= 50]
  
  pb <- SingleCellExperiment(list(counts = counts(pb)), 
                             colData = colData(pb) %>% 
                               data.frame %>% 
                               dplyr::select(c("sample_id", "donor_id", "age_years", "sex", 
                                               "sample_barcode", "tissue", "batch_name", "ncells")) %>% 
                               DataFrame) %>% 
    addPerCellQCMetrics()
  
  pb$age_category <- ifelse(pb$age_years <= 5, 'preschool', 
                            ifelse(pb$age_years > 5 & pb$age_years <= 11, 'early_childhood', 
                                   ifelse(pb$age_years > 11, 'adolescent', NA)))
  
  pb <- logNormCounts(pb) %>% runPCA()
  
  dge <- DGEList(counts = counts(pb), samples = colData(pb) %>% data.frame)  
  keep <- rowSums(dge$counts) > 0
  dge <- dge[keep, ]
  dge <- calcNormFactors(dge)

  design <- model.matrix(~ dge$samples$age_years + dge$samples$sex +  dge$samples$batch_name)

  v <- voom(dge, design, plot = FALSE)
  fit <- lmFit(v, design)
  fit <- eBayes(fit)
  dt <- decideTests(fit)
  
  top_genes <- topTable(fit, coef = 2, number = Inf, adjust.method = "BH")
  dge_res <- summary(dt)
  
  summary_list[[celltype]] <- top_genes
  summary_list1[[celltype]] <- dge_res
}
Processing: Naïve B cells 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: Plasma B cells 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: Monocytes/macrophages 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: Naïve B cells activated 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: Memory B cells 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: Naïve B cell-IFN 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: Pre-BCRi II 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: Follicular dendritic cells 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: DZ G2Mphase 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: DZtoLZ GCB transition 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: DZ early  Sphase 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: DZ GCB 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: Early GC-committed NBC 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: Early PC precursor 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: Cycling GCB 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: CD4 effector 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: TFH-LZ-GC 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: Gamma delta T 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: CD4 Treg 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: CD4 TFH 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: CD8 TN 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: CD4 TN 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: T-IFN 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: CD8 TF 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: CD4 Treg-eff 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: CD4 TCM 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
Processing: Double negative T 
Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
singular values/vectors requested than available
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
TRUE, : You're computing too large a percentage of total singular values, use a
standard svd instead.
summary_table <- do.call(rbind, lapply(names(summary_list), function(x) 
  data.frame(CellType = x, summary_list[[x]])))

summary_table1 <- do.call(rbind, lapply(names(summary_list1), function(x) 
  data.frame(CellType = x, summary_list1[[x]])))

#print(head(summary_table))
print(summary_list1)
$`Naïve B cells`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down          3943                    61               19
NotSig         948                 15021            15101
Up           10239                    48               10
       dge$samples$batch_nameG000231_batch9
Down                                   2523
NotSig                                 9342
Up                                     3265

$`Plasma B cells`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down          4858                    28                9
NotSig        1152                 15281            15334
Up            9342                    43                9
       dge$samples$batch_nameG000231_batch9
Down                                   1780
NotSig                                10956
Up                                     2616

$`Monocytes/macrophages`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down             0                     0                0
NotSig        3237                 14919            14915
Up           11684                     2                6
       dge$samples$batch_nameG000231_batch9
Down                                    620
NotSig                                13723
Up                                      578

$`Naïve B cells activated`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down             0                  2551                8
NotSig        3109                 11335            14058
Up           10964                   187                7
       dge$samples$batch_nameG000231_batch9
Down                                   1636
NotSig                                 8177
Up                                     4260

$`Memory B cells`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down          3757                  2260               17
NotSig        1130                 12905            15296
Up           10435                   157                9
       dge$samples$batch_nameG000231_batch9
Down                                   2799
NotSig                                 6483
Up                                     6040

$`Naïve B cell-IFN`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down            22                     1                9
NotSig        3835                 14086            14076
Up           10234                     4                6
       dge$samples$batch_nameG000231_batch9
Down                                    937
NotSig                                12048
Up                                     1106

$`Pre-BCRi II`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down             0                     0                0
NotSig           0                 13448            13443
Up           13449                     1                6
       dge$samples$batch_nameG000231_batch9
Down                                   3625
NotSig                                 8194
Up                                     1630

$`Follicular dendritic cells`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down             1                     0                0
NotSig        3077                 14596            14591
Up           11518                     0                5
       dge$samples$batch_nameG000231_batch9
Down                                      3
NotSig                                14588
Up                                        5

$`DZ G2Mphase`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down          4743                     0               21
NotSig         767                 15653            15610
Up           10143                     0               22
       dge$samples$batch_nameG000231_batch9
Down                                   3109
NotSig                                 5370
Up                                     7174

$`DZtoLZ GCB transition`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down             2                    28               11
NotSig        3847                 14290            14317
Up           10487                    18                8
       dge$samples$batch_nameG000231_batch9
Down                                   5568
NotSig                                 6947
Up                                     1821

$`DZ early  Sphase`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down          3586                     0               19
NotSig        1072                 14925            14897
Up           10267                     0                9
       dge$samples$batch_nameG000231_batch9
Down                                   1980
NotSig                                10586
Up                                     2359

$`DZ GCB`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down          3593                     0               23
NotSig        1097                 14706            14674
Up           10016                     0                9
       dge$samples$batch_nameG000231_batch9
Down                                   1885
NotSig                                10867
Up                                     1954

$`Early GC-committed NBC`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down          3304                     0               22
NotSig        1264                 14640            14608
Up           10072                     0               10
       dge$samples$batch_nameG000231_batch9
Down                                   1951
NotSig                                10783
Up                                     1906

$`Early PC precursor`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down             0                     0                2
NotSig        2889                 12701            12692
Up            9812                     0                7
       dge$samples$batch_nameG000231_batch9
Down                                    124
NotSig                                12373
Up                                      204

$`Cycling GCB`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down             4                     0               15
NotSig        3712                 13748            13724
Up           10033                     1               10
       dge$samples$batch_nameG000231_batch9
Down                                   1449
NotSig                                10676
Up                                     1624

$`CD4 effector`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down             0                     5                4
NotSig         570                 13381            13383
Up           12823                     7                6
       dge$samples$batch_nameG000231_batch9
Down                                    601
NotSig                                12236
Up                                      556

$`TFH-LZ-GC`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down             0                    50                6
NotSig          12                 13819            13881
Up           13883                    26                8
       dge$samples$batch_nameG000231_batch9
Down                                   1009
NotSig                                11841
Up                                     1045

$`Gamma delta T`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down             0                     0               10
NotSig        1489                 12573            12553
Up           11084                     0               10
       dge$samples$batch_nameG000231_batch9
Down                                     49
NotSig                                12484
Up                                       40

$`CD4 Treg`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down             0                     0                0
NotSig         217                 12824            12818
Up           12607                     0                6
       dge$samples$batch_nameG000231_batch9
Down                                    127
NotSig                                12597
Up                                      100

$`CD4 TFH`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down          2938                     2               10
NotSig        1308                 14623            14607
Up           10383                     4               12
       dge$samples$batch_nameG000231_batch9
Down                                   1993
NotSig                                10489
Up                                     2147

$`CD8 TN`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down             0                     0                5
NotSig        2480                 13483            13471
Up           11003                     0                7
       dge$samples$batch_nameG000231_batch9
Down                                    672
NotSig                                12092
Up                                      719

$`CD4 TN`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down             9                     0                8
NotSig        3708                 14298            14282
Up           10581                     0                8
       dge$samples$batch_nameG000231_batch9
Down                                   1225
NotSig                                11729
Up                                     1344

$`T-IFN`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down             0                     0                0
NotSig        2244                 12974            12970
Up           10730                     0                4
       dge$samples$batch_nameG000231_batch9
Down                                      0
NotSig                                12974
Up                                        0

$`CD8 TF`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down             0                     0                1
NotSig         553                 13649            13641
Up           13096                     0                7
       dge$samples$batch_nameG000231_batch9
Down                                    520
NotSig                                12649
Up                                      480

$`CD4 Treg-eff`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down             0                     1                5
NotSig        3077                 13848            13837
Up           10772                     0                7
       dge$samples$batch_nameG000231_batch9
Down                                    917
NotSig                                12002
Up                                      930

$`CD4 TCM`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down             0                     1                2
NotSig          88                 13260            13255
Up           13175                     2                6
       dge$samples$batch_nameG000231_batch9
Down                                    394
NotSig                                12460
Up                                      409

$`Double negative T`
       (Intercept) dge$samples$age_years dge$samples$sexM
Down             0                     0                1
NotSig        2326                 12347            12342
Up           10021                     0                4
       dge$samples$batch_nameG000231_batch9
Down                                      1
NotSig                                12346
Up                                        0
age_summary_table <- summary_table1 %>%
  filter(grepl("dge\\$samples\\$age_years", Var2)) %>%
  pivot_wider(names_from = Var1, values_from = Freq, values_fill = list(Freq = 0))

print(knitr::kable(age_summary_table, caption = "DGE Age summary: Tonsils earlyAIR"))


Table: DGE Age summary: Tonsils earlyAIR

|CellType                   |Var2                  | Down| NotSig|  Up|
|:--------------------------|:---------------------|----:|------:|---:|
|Naïve B cells              |dge$samples$age_years |   61|  15021|  48|
|Plasma B cells             |dge$samples$age_years |   28|  15281|  43|
|Monocytes/macrophages      |dge$samples$age_years |    0|  14919|   2|
|Naïve B cells activated    |dge$samples$age_years | 2551|  11335| 187|
|Memory B cells             |dge$samples$age_years | 2260|  12905| 157|
|Naïve B cell-IFN           |dge$samples$age_years |    1|  14086|   4|
|Pre-BCRi II                |dge$samples$age_years |    0|  13448|   1|
|Follicular dendritic cells |dge$samples$age_years |    0|  14596|   0|
|DZ G2Mphase                |dge$samples$age_years |    0|  15653|   0|
|DZtoLZ GCB transition      |dge$samples$age_years |   28|  14290|  18|
|DZ early  Sphase           |dge$samples$age_years |    0|  14925|   0|
|DZ GCB                     |dge$samples$age_years |    0|  14706|   0|
|Early GC-committed NBC     |dge$samples$age_years |    0|  14640|   0|
|Early PC precursor         |dge$samples$age_years |    0|  12701|   0|
|Cycling GCB                |dge$samples$age_years |    0|  13748|   1|
|CD4 effector               |dge$samples$age_years |    5|  13381|   7|
|TFH-LZ-GC                  |dge$samples$age_years |   50|  13819|  26|
|Gamma delta T              |dge$samples$age_years |    0|  12573|   0|
|CD4 Treg                   |dge$samples$age_years |    0|  12824|   0|
|CD4 TFH                    |dge$samples$age_years |    2|  14623|   4|
|CD8 TN                     |dge$samples$age_years |    0|  13483|   0|
|CD4 TN                     |dge$samples$age_years |    0|  14298|   0|
|T-IFN                      |dge$samples$age_years |    0|  12974|   0|
|CD8 TF                     |dge$samples$age_years |    0|  13649|   0|
|CD4 Treg-eff               |dge$samples$age_years |    1|  13848|   0|
|CD4 TCM                    |dge$samples$age_years |    1|  13260|   2|
|Double negative T          |dge$samples$age_years |    0|  12347|   0|
#writexl::write_xlsx(age_summary_table, path = here("output/DGE/Tonsils/DGE_Age_summary_Tonsils.xlsx"))

sessionInfo()
R version 4.3.2 (2023-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS 15.3

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Australia/Melbourne
tzcode source: internal

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

other attached packages:
 [1] Glimma_2.12.0               org.Hs.eg.db_3.18.0        
 [3] AnnotationDbi_1.64.1        BiocStyle_2.30.0           
 [5] knitr_1.45                  edgeR_4.0.16               
 [7] limma_3.58.1                speckle_1.2.0              
 [9] ggridges_0.5.6              scater_1.30.1              
[11] scran_1.30.2                scuttle_1.12.0             
[13] SingleCellExperiment_1.24.0 SummarizedExperiment_1.32.0
[15] Biobase_2.62.0              GenomicRanges_1.54.1       
[17] GenomeInfoDb_1.38.6         IRanges_2.36.0             
[19] S4Vectors_0.40.2            BiocGenerics_0.48.1        
[21] MatrixGenerics_1.14.0       matrixStats_1.2.0          
[23] viridis_0.6.5               viridisLite_0.4.2          
[25] paletteer_1.6.0             gridExtra_2.3              
[27] lubridate_1.9.3             forcats_1.0.0              
[29] stringr_1.5.1               purrr_1.0.2                
[31] readr_2.1.5                 tidyr_1.3.1                
[33] tibble_3.2.1                ggplot2_3.5.0              
[35] tidyverse_2.0.0             dplyr_1.1.4                
[37] Seurat_5.0.1.9009           SeuratObject_5.0.1         
[39] sp_2.1-3                    patchwork_1.2.0            
[41] glue_1.7.0                  here_1.0.1                 
[43] workflowr_1.7.1            

loaded via a namespace (and not attached):
  [1] fs_1.6.3                  spatstat.sparse_3.0-3    
  [3] bitops_1.0-7              httr_1.4.7               
  [5] RColorBrewer_1.1-3        tools_4.3.2              
  [7] sctransform_0.4.1         utf8_1.2.4               
  [9] R6_2.5.1                  lazyeval_0.2.2           
 [11] uwot_0.1.16               withr_3.0.0              
 [13] progressr_0.14.0          cli_3.6.2                
 [15] spatstat.explore_3.2-6    fastDummies_1.7.3        
 [17] sass_0.4.8                spatstat.data_3.0-4      
 [19] pbapply_1.7-2             parallelly_1.37.0        
 [21] rstudioapi_0.15.0         RSQLite_2.3.5            
 [23] generics_0.1.3            ica_1.0-3                
 [25] spatstat.random_3.2-2     Matrix_1.6-5             
 [27] ggbeeswarm_0.7.2          fansi_1.0.6              
 [29] abind_1.4-5               lifecycle_1.0.4          
 [31] whisker_0.4.1             yaml_2.3.8               
 [33] SparseArray_1.2.4         Rtsne_0.17               
 [35] grid_4.3.2                blob_1.2.4               
 [37] promises_1.2.1            dqrng_0.3.2              
 [39] crayon_1.5.2              miniUI_0.1.1.1           
 [41] lattice_0.22-5            beachmat_2.18.1          
 [43] cowplot_1.1.3             KEGGREST_1.42.0          
 [45] pillar_1.9.0              metapod_1.10.1           
 [47] future.apply_1.11.1       codetools_0.2-19         
 [49] leiden_0.4.3.1            getPass_0.2-4            
 [51] data.table_1.15.0         vctrs_0.6.5              
 [53] png_0.1-8                 spam_2.10-0              
 [55] gtable_0.3.4              rematch2_2.1.2           
 [57] cachem_1.0.8              xfun_0.42                
 [59] S4Arrays_1.2.0            mime_0.12                
 [61] survival_3.5-8            statmod_1.5.0            
 [63] bluster_1.12.0            ellipsis_0.3.2           
 [65] fitdistrplus_1.1-11       ROCR_1.0-11              
 [67] nlme_3.1-164              bit64_4.0.5              
 [69] RcppAnnoy_0.0.22          rprojroot_2.0.4          
 [71] bslib_0.6.1               irlba_2.3.5.1            
 [73] vipor_0.4.7               KernSmooth_2.23-22       
 [75] colorspace_2.1-0          DBI_1.2.2                
 [77] DESeq2_1.42.1             tidyselect_1.2.0         
 [79] processx_3.8.3            bit_4.0.5                
 [81] compiler_4.3.2            git2r_0.33.0             
 [83] BiocNeighbors_1.20.2      DelayedArray_0.28.0      
 [85] plotly_4.10.4             scales_1.3.0             
 [87] lmtest_0.9-40             callr_3.7.5              
 [89] digest_0.6.34             goftest_1.2-3            
 [91] spatstat.utils_3.0-4      rmarkdown_2.25           
 [93] XVector_0.42.0            htmltools_0.5.7          
 [95] pkgconfig_2.0.3           sparseMatrixStats_1.14.0 
 [97] fastmap_1.1.1             rlang_1.1.3              
 [99] htmlwidgets_1.6.4         shiny_1.8.0              
[101] DelayedMatrixStats_1.24.0 jquerylib_0.1.4          
[103] zoo_1.8-12                jsonlite_1.8.8           
[105] BiocParallel_1.36.0       BiocSingular_1.18.0      
[107] RCurl_1.98-1.14           magrittr_2.0.3           
[109] GenomeInfoDbData_1.2.11   dotCall64_1.1-1          
[111] munsell_0.5.0             Rcpp_1.0.12              
[113] reticulate_1.35.0         stringi_1.8.3            
[115] zlibbioc_1.48.0           MASS_7.3-60.0.1          
[117] plyr_1.8.9                parallel_4.3.2           
[119] listenv_0.9.1             ggrepel_0.9.5            
[121] deldir_2.0-2              Biostrings_2.70.2        
[123] splines_4.3.2             tensor_1.5               
[125] hms_1.1.3                 locfit_1.5-9.8           
[127] ps_1.7.6                  igraph_2.0.2             
[129] spatstat.geom_3.2-8       RcppHNSW_0.6.0           
[131] reshape2_1.4.4            ScaledMatrix_1.10.0      
[133] evaluate_0.23             BiocManager_1.30.22      
[135] tzdb_0.4.0                httpuv_1.6.14            
[137] RANN_2.6.1                polyclip_1.10-6          
[139] future_1.33.1             scattermore_1.2          
[141] rsvd_1.0.5                xtable_1.8-4             
[143] RSpectra_0.16-1           later_1.3.2              
[145] memoise_2.0.1             beeswarm_0.4.0           
[147] cluster_2.1.6             timechange_0.3.0         
[149] globals_0.16.2