Main (top 5)
The published version: Top Genes +/- and Top
Proteins +/- list the top 5 features per direction. Download
the raw CSV at figures/final-selected/ExtendedDataTable1_GP_summary.csv.
Last updated: 2026-07-31
Checks: 7 0
Knit directory:
immgenT-GP-analysis/analysis/
This reproducible R Markdown analysis was created with workflowr (version 1.7.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(1) 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 80f61c0. 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: .claude/
Ignored: analysis/.DS_Store
Ignored: analysis/.Rhistory
Ignored: analysis/assets/.DS_Store
Ignored: captions/
Ignored: code/.DS_Store
Ignored: code/other/topic_flashier_20250212.R
Ignored: code/other/topic_wrapper_20250215_alldata_backfit.sh
Ignored: data
Ignored: experiments/
Ignored: figures/.DS_Store
Ignored: figures/Previous/.DS_Store
Ignored: figures/Previous/bits/.DS_Store
Ignored: figures/Previous/bits/Figure 1/.DS_Store
Ignored: figures/Previous/bits/Figure 2/.DS_Store
Ignored: figures/Previous/bits/Figure 3/.DS_Store
Ignored: figures/Previous/bits/Figure 4/.DS_Store
Ignored: figures/Previous/bits/Figure 6/.DS_Store
Ignored: figures/Previous/bits/Figure 7/.DS_Store
Ignored: figures/Previous/bits/Figure S1/.DS_Store
Ignored: figures/Previous/bits/Figure S2/.DS_Store
Ignored: figures/Previous/bits/Figure S3/.DS_Store
Ignored: figures/Previous/bits/Figure S6/.DS_Store
Ignored: figures/Previous/bits/Figure S7/.DS_Store
Ignored: figures/final-selected/.DS_Store
Ignored: figures/final-selected/Figure 1/.DS_Store
Ignored: figures/final-selected/Figure 2/.DS_Store
Ignored: figures/final-selected/Figure 4/.DS_Store
Ignored: figures/final-selected/Figure S1/.DS_Store
Ignored: figures/final-selected/Figure S4/.DS_Store
Ignored: figures/templates_20260729/
Ignored: log/
Ignored: output/.DS_Store
Ignored: output/Figure2/
Ignored: output/Figure7b/7b_cell_metadata.csv.gz
Ignored: plan/
Ignored: tables/
Ignored: tmp/
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/ExtendedDataTable1.Rmd)
and HTML (docs/ExtendedDataTable1.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 | 80f61c0 | Ziang Zhang | 2026-07-31 | Extended Data Table 1: manual annotations + longer internal version |
| html | cbcec52 | Ziang Zhang | 2026-07-30 | Build site: Extended Data Figure naming |
| html | ac650a0 | Ziang Zhang | 2026-07-30 | Build site: Figure S5 (ex-S6a) and Figure S6 as a-f |
| html | ae21d37 | Ziang Zhang | 2026-07-28 | Build site: republish after the reorder commits |
| html | d538aa2 | Ziang Zhang | 2026-07-28 | Build site: reordered Figures 6 / S6 / S3 and the new Figure 7b page |
| html | 029b0ae | Ziang Zhang | 2026-07-28 | Build site. |
| html | 3fc3789 | Ziang Zhang | 2026-07-27 | Republish all 24 pages |
| html | 1390a03 | Ziang Zhang | 2026-07-27 | Republish all 24 pages |
| html | adaef21 | Ziang Zhang | 2026-07-27 | Build site: panel fixes and PDF-derived assets |
| html | 5b19858 | Ziang Zhang | 2026-07-27 | Build site. |
| Rmd | ffe285c | Ziang Zhang | 2026-07-27 | Reorganize figures/ and untrack local-only exploration notes |
| Rmd | b197499 | Ziang Zhang | 2026-07-16 | Restructure main figures (renumber + split Figure 1) |
| html | b197499 | Ziang Zhang | 2026-07-16 | Restructure main figures (renumber + split Figure 1) |
| html | 362ebf9 | Ziang Zhang | 2026-07-05 | Build site. |
| Rmd | 0fc11c3 | Ziang Zhang | 2026-07-05 | Make Extended Data Tables interactive (DT); rename Table 1’s signature columns |
| html | 92d1365 | Ziang Zhang | 2026-07-05 | Build site. |
| Rmd | d07f797 | Ziang Zhang | 2026-07-05 | Replace Table S1/S2/S3 with 7 fully-reproducible Extended Data Tables |
Produced by script/ExtendedDataTable1_GP_summary.R:
# Extended Data Table 1: summary of GP characteristics and annotations.
#
# One row per GP (GP1..GP200) with:
# - Annotation: the manual, human-written description of the GP, read from the
# curated curation/GP_manual_annotations.csv (blank where a GP has not been
# annotated yet). That CSV is the single source of truth -- it replaces the
# `annotation` column of the retired hand-maintained Table S1.xlsx.
# - Lineage / Cluster / Tissue: the categories each GP *positively* predicts
# well -- one-vs-rest AUC > 0.8 AND the optimal decision threshold at or
# above the GP's median loading, so high loading (not low) drives the
# prediction. Categories are annotation_level1 (lineage), annotation_level2
# (cluster) and organ_simplified (tissue), all from the healthy
# non-thymocyte AUC family (*_no_thymocytes_healthy, same population as
# Figure 2/Figure 4); the median loading is likewise computed on the healthy
# non-thymocyte cells so the threshold comparison is on the same population.
# - Signature genes / proteins: the top up- and top down-regulated genes and
# proteins by factor score, among those with |score| > 0.1 on the
# max|.|=1-per-GP-scaled gene (F_pm_filtered) and protein (Figure 6's
# Protein_F_pm) factor matrices.
#
# Two versions are written, identical except for how many features each
# signature column lists (same cutoff, same ranking -- the top 5 lists are
# exactly the first 5 entries of the top 15 lists):
# - ExtendedDataTable1_GP_summary.csv top 5 per direction (published)
# - ExtendedDataTable1_GP_summary_top15.csv top 15 per direction (internal)
#
# Reworks the retired Table S1 (script/TableS1.R): drops its Condition column,
# switches the annotations from the non-thymocyte healthy+diseased AUC to the
# healthy non-thymocyte AUC, adds protein signatures, and loosens the gene
# signature cutoff from 0.25 to 0.1.
data_path <- "data/"
curation_path <- "curation/"
output_path <- "figures/final-selected/"
# ---- Protein factor matrix (Figure 6's Protein_F_pm: filtered + max|.|=1 per
# GP column). Load, extract, and drop the heavy fit before loading L. ----
Protein_flash_result <- readRDS(paste0(data_path, "protein_flash_selected_summary_lognorm_backfit200.rds"))
Protein_F_pm_raw <- Protein_flash_result$F_pm
rm(Protein_flash_result); gc()
isotype_proteins <- grep("^Isotype", rownames(Protein_F_pm_raw), value = TRUE)
proteins_quality <- read.csv(paste0(data_path, "TableS4_citeseq_qc_20250513.csv"), header = TRUE, stringsAsFactors = FALSE, skip = 1)
good_proteins <- c(proteins_quality$protein[proteins_quality$classification == "good"], "IL2RA.CD25", "ITB7", "CD69")
exclude_proteins <- c("CD19", "CD34", "CD45.1", "CD45.2", "CD138", "TCRVA2", "TER119")
thy11_proteins <- grep("THY1.1", rownames(Protein_F_pm_raw), value = TRUE)
Protein_F_pm <- Protein_F_pm_raw[!rownames(Protein_F_pm_raw) %in% isotype_proteins, ]
Protein_F_pm <- Protein_F_pm[rownames(Protein_F_pm) %in% good_proteins, ]
Protein_F_pm <- Protein_F_pm[!rownames(Protein_F_pm) %in% exclude_proteins, ]
Protein_F_pm <- Protein_F_pm[!rownames(Protein_F_pm) %in% thy11_proteins, ]
D_lognorm <- diag(1 / apply(Protein_F_pm, 2, function(x) max(abs(x))))
Protein_F_pm <- Protein_F_pm %*% D_lognorm
Protein_F_pm[is.na(Protein_F_pm)] <- 0
# ---- Loadings, gene factor matrix, healthy non-thymocyte AUC ----
# L_pm_filtered / F_pm_filtered and the cached AUC matrices all share the raw
# "K1","K2",... column names (from the flashier fit); keep them for matching and
# relabel to "GP1","GP2",... only for output.
L_pm_filtered <- readRDS(paste0(data_path, "L_pm_filtered.rds"))
F_pm_filtered <- readRDS(paste0(data_path, "F_pm_filtered.rds"))
level_1_AUC_list <- readRDS(paste0(data_path, "level_1_AUC_list_figure_no_thymocytes_healthy.rds"))
level_2_AUC_list <- readRDS(paste0(data_path, "level_2_AUC_list_figure_no_thymocytes_healthy.rds"))
organ_AUC_list <- readRDS(paste0(data_path, "organ_simplified_AUC_list_figure_no_thymocytes_healthy.rds"))
# Use L_pm_filtered's "K1".."K200" names as the canonical GP key: the AUC
# matrices carry these same names, whereas F_pm_filtered's raw columns are
# "F1".."F200" and the protein factor columns are unnamed -- but all three are
# in the same factor order as L (same flashier fit / fixed-loading projection),
# so relabeling them to L's K-names aligns every signature/annotation lookup.
gps <- colnames(L_pm_filtered) # "K1".."K200"
gp_labels <- paste0("GP", seq_along(gps))
colnames(Protein_F_pm) <- gps
# Normalize the gene factor matrix so each GP column has max|score| = 1.
F_pm_filtered <- apply(F_pm_filtered, 2, function(x) x / max(abs(x)))
colnames(F_pm_filtered) <- gps
# ---- Median loading on the healthy non-thymocyte cell subset ----
seurat_meta <- readRDS(paste0(data_path, "igt1_96_withtotalvi20260206_clean_ADTonly.Rds"))@meta.data
seurat_meta_filtered <- seurat_meta[rownames(L_pm_filtered), ]
rm(seurat_meta); gc()
# which() drops any cells whose condition/lineage metadata is NA (so they don't
# leak in as NA rows and turn every median into NA). seurat_meta_filtered is row-
# aligned to L_pm_filtered, so the integer index selects the matching L rows.
healthy_nonthy_idx <- which(
seurat_meta_filtered$condition_broad == "healthy" &
seurat_meta_filtered$annotation_level1 != "thymocyte"
)
L_healthy_nonthy <- L_pm_filtered[healthy_nonthy_idx, , drop = FALSE]
# ---- Positively-predicted categories: AUC > 0.8 and threshold >= median
# loading (so high loading drives the prediction) ----
get_passing_categories <- function(auc_list, gps, L_mat, threshold = 0.8) {
auc_mat <- auc_list$auc
thr_mat <- auc_list$threshold
gp_median_loading <- apply(L_mat, 2, median)
lapply(gps, function(gp) {
if (!gp %in% colnames(auc_mat)) return("")
auc_vals <- auc_mat[, gp]
thr_vals <- thr_mat[, gp]
med_load <- gp_median_loading[gp]
pass <- !is.na(auc_vals) & !is.na(thr_vals) &
auc_vals > threshold & thr_vals >= med_load
cats <- rownames(auc_mat)[pass]
paste(cats, collapse = "; ")
})
}
lineage_cats <- get_passing_categories(level_1_AUC_list, gps, L_healthy_nonthy)
cluster_cats <- get_passing_categories(level_2_AUC_list, gps, L_healthy_nonthy)
tissue_cats <- get_passing_categories(organ_AUC_list, gps, L_healthy_nonthy)
# ---- Manual annotations (curated input; blank where not yet annotated) ----
# Keyed by the GP*n* output labels, not the internal K-names. Insisting on an
# exact GP1..GP200 match means a renamed or dropped row fails loudly here
# instead of silently blanking an annotation in the published table.
manual_ann <- read.csv(paste0(curation_path, "GP_manual_annotations.csv"),
stringsAsFactors = FALSE, colClasses = "character")
stopifnot(identical(manual_ann$GP, gp_labels))
annotation <- trimws(manual_ann$Annotation)
# ---- Top n up / down signature genes and proteins (|score| > 0.1) ----
top_signatures <- function(score_mat, gps, cutoff = 0.1, n = 5) {
pos <- lapply(gps, function(gp) {
vals <- score_mat[, gp]
cand <- names(vals)[vals > cutoff]
top <- head(cand[order(vals[cand], decreasing = TRUE)], n)
paste(top, collapse = "; ")
})
neg <- lapply(gps, function(gp) {
vals <- score_mat[, gp]
cand <- names(vals)[vals < -cutoff]
top <- head(cand[order(abs(vals[cand]), decreasing = TRUE)], n)
paste(top, collapse = "; ")
})
list(pos = unlist(pos), neg = unlist(neg))
}
build_table <- function(n) {
gene_sig <- top_signatures(F_pm_filtered, gps, n = n)
prot_sig <- top_signatures(Protein_F_pm, gps, n = n)
supp_table <- data.frame(
GP = gp_labels,
Annotation = annotation,
Lineage = unlist(lineage_cats),
Cluster = unlist(cluster_cats),
Tissue = unlist(tissue_cats),
Signature_Genes_Pos = gene_sig$pos,
Signature_Genes_Neg = gene_sig$neg,
Signature_Proteins_Pos = prot_sig$pos,
Signature_Proteins_Neg = prot_sig$neg,
stringsAsFactors = FALSE
)
colnames(supp_table) <- c(
"GP", "Annotation", "Lineage", "Cluster", "Tissue",
"Top Genes +", "Top Genes -", "Top Proteins +", "Top Proteins -"
)
supp_table
}
versions <- list(
"ExtendedDataTable1_GP_summary.csv" = 5,
"ExtendedDataTable1_GP_summary_top15.csv" = 15
)
for (fname in names(versions)) {
write.csv(
build_table(versions[[fname]]),
file = paste0(output_path, fname),
row.names = FALSE
)
}
Two versions of the same table are available below – click a tab to switch. They differ only in how many features the signature columns list; everything else, including the manual Annotation column, is identical.
In either version all 200 rows are browsable: sort by clicking a
column header, use the search boxes under each header to filter
(e.g. type a GP name, a lineage like CD8, or an annotation
keyword like batch), or use the box in the top-right corner
for a free-text search across every column.
The published version: Top Genes +/- and Top
Proteins +/- list the top 5 features per direction. Download
the raw CSV at figures/final-selected/ExtendedDataTable1_GP_summary.csv.
The same table with up to 15 features per direction instead of 5 –
same |score| > 0.1 cutoff and same ranking, so each cell above is
exactly the first 5 entries of the cell here. GPs with fewer than 15
qualifying features list all of them. Download the raw CSV at figures/final-selected/ExtendedDataTable1_GP_summary_top15.csv.
Extended Data Table 1. One row per GP.
Annotation is the manual, human-written description of
the GP, maintained by hand in curation/GP_manual_annotations.csv
and blank for GPs not yet annotated; that file replaces the
annotation column of the retired hand-maintained
Table S1.xlsx, and this table is now where the annotations
are published. Lineage, Cluster and
Tissue list the categories (annotation_level1,
annotation_level2, organ_simplified) that the GP positively
predicts well – one-vs-rest AUC > 0.8 and the optimal decision
threshold at or above the GP’s median loading, so high (not low) loading
drives the prediction – computed on healthy non-thymocyte cells (the
same population as Figure 3 / Figure 5), with the median loading taken
on that same population. Top Genes +/- and Top
Proteins +/- give the top up- and top down-regulated genes and
proteins by factor score, among those with |score| > 0.1 on the
max|.|=1-per-GP-scaled gene and protein factor matrices – 5 per
direction in the main version, 15 in the longer internal version.
sessionInfo()
R version 4.5.1 (2025-06-13)
Platform: aarch64-apple-darwin20
Running under: macOS Sequoia 15.6.1
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.1
locale:
[1] en_CA/en_CA/en_CA/C/en_CA/en_CA
time zone: America/Chicago
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] DT_0.34.0
loaded via a namespace (and not attached):
[1] vctrs_0.7.3 cli_3.6.6 knitr_1.50 rlang_1.2.0
[5] xfun_0.55 stringi_1.8.7 otel_0.2.0 promises_1.5.0
[9] jsonlite_2.0.0 workflowr_1.7.2 glue_1.8.1 rprojroot_2.1.1
[13] git2r_0.36.2 htmltools_0.5.9 httpuv_1.6.16 sass_0.4.10
[17] rmarkdown_2.30 crosstalk_1.2.2 evaluate_1.0.5 jquerylib_0.1.4
[21] tibble_3.3.0 fastmap_1.2.0 yaml_2.3.12 lifecycle_1.0.5
[25] whisker_0.4.1 stringr_1.6.0 compiler_4.5.1 fs_1.6.6
[29] htmlwidgets_1.6.4 Rcpp_1.1.1-1.1 pkgconfig_2.0.3 later_1.4.4
[33] digest_0.6.39 R6_2.6.1 pillar_1.11.1 magrittr_2.0.5
[37] bslib_0.9.0 tools_4.5.1 cachem_1.1.0