Last updated: 2026-07-05

Checks: 6 1

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.


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(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 6d1c6c0. 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:    code/.DS_Store
    Ignored:    data
    Ignored:    figures/final-selected/.DS_Store
    Ignored:    figures/final-selected/bits/.DS_Store
    Ignored:    figures/final-selected/bits/Figure 1/.DS_Store
    Ignored:    figures/final-selected/bits/Figure 2/.DS_Store
    Ignored:    figures/final-selected/bits/Figure 3/.DS_Store
    Ignored:    figures/final-selected/bits/Figure 4/.DS_Store
    Ignored:    figures/final-selected/bits/Figure 6/.DS_Store
    Ignored:    figures/final-selected/bits/Figure 7/.DS_Store
    Ignored:    figures/final-selected/bits/Figure S1/.DS_Store
    Ignored:    figures/final-selected/bits/Figure S2/.DS_Store
    Ignored:    figures/final-selected/bits/Figure S3/.DS_Store
    Ignored:    figures/final-selected/bits/Figure S6/.DS_Store
    Ignored:    figures/final-selected/bits/Figure S7/.DS_Store
    Ignored:    figures/generated/.DS_Store
    Ignored:    figures/generated/Figure 5/
    Ignored:    figures/generated/Figure 7/
    Ignored:    figures/generated/Figure 8/
    Ignored:    figures/generated/Figure 9/

Untracked files:
    Untracked:  analysis/ExtendedDataTable1.Rmd
    Untracked:  analysis/ExtendedDataTable2.Rmd
    Untracked:  analysis/ExtendedDataTable3.Rmd
    Untracked:  analysis/ExtendedDataTable4.Rmd
    Untracked:  analysis/ExtendedDataTable5.Rmd
    Untracked:  analysis/ExtendedDataTable6.Rmd
    Untracked:  analysis/ExtendedDataTable7.Rmd
    Untracked:  figures/generated/ExtendedDataTable1_GP_summary.csv
    Untracked:  figures/generated/ExtendedDataTable2_GP_AUC_lineage.csv
    Untracked:  figures/generated/ExtendedDataTable3_GP_AUC_tissue.csv
    Untracked:  figures/generated/ExtendedDataTable4_GP_AUC_cluster.csv
    Untracked:  figures/generated/ExtendedDataTable5_GP_during_activation.csv
    Untracked:  figures/generated/ExtendedDataTable6_protein_factor_matrix.csv
    Untracked:  figures/generated/ExtendedDataTable7_protein_gating.csv
    Untracked:  script/ExtendedDataTable1_GP_summary.R
    Untracked:  script/ExtendedDataTable2_GP_AUC_lineage.R
    Untracked:  script/ExtendedDataTable3_GP_AUC_tissue.R
    Untracked:  script/ExtendedDataTable4_GP_AUC_cluster.R
    Untracked:  script/ExtendedDataTable5_GP_during_activation.R
    Untracked:  script/ExtendedDataTable6_protein_factor_matrix.R
    Untracked:  script/ExtendedDataTable7_protein_gating.R
    Untracked:  tables/

Unstaged changes:
    Deleted:    analysis/TableS1.Rmd
    Modified:   analysis/index.Rmd
    Modified:   code/R/gated_protein_helpers.R
    Modified:   code/R/roc_auc.R
    Modified:   code/README.md
    Modified:   code/pipeline/02_compute_auc.R
    Deleted:    figures/generated/Supplementary_Table1_GP_summary.csv
    Modified:   script/README.md
    Deleted:    script/TableS1.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.


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


Produced by script/ExtendedDataTable7_protein_gating.R:

# Extended Data Table 7: protein gating.
#
# One row per GP: its curated positive/negative protein-marker signature, and
# how well a protein gate built from that signature recovers cells with high GP
# loading. For each GP we gate cells by its markers (positive markers above
# their threshold, negative markers at/below), then measure the proportion of
# gated cells that are "positive" for the GP (loading > 0.1; the True Discovery
# Proportion) versus that proportion among all cells, and flag GPs whose gate is
# well aligned with the GP loading.
#
# Reproduces the published data/CITEseq_alignment_scores_manual.csv (Table S3):
# compute_alignment_scores() + format_scores_table() (code/R/gated_protein_helpers.R)
# run on the manually-curated marker set df_markers2 from
# code/R/citeseq_shared_setup.R. Here we keep the presentation subset of columns
# used in Table S3.

library(dplyr)
library(Matrix) # protein matrices are dgCMatrix; must be attached for `[` to dispatch

data_path <- "data/"
output_path <- "figures/generated/"

source("code/R/gated_protein_helpers.R") # compute_alignment_scores(), format_scores_table()
source("code/R/citeseq_shared_setup.R")  # df_markers2, L_pm_filtered, protein_mat_normalized_lognorm,
                                         # threshold_results_subset_manual, select_proteins, *_cells

scores_manual <- compute_alignment_scores(
  df_m = df_markers2,
  protein_mat = protein_mat_normalized_lognorm,
  loading_mat = L_pm_filtered,
  threshold_df = threshold_results_subset_manual,
  selected_proteins = select_proteins,
  exclude_cells = c(thymocyte_cells, proliferating_cells, miniverse_cells),
  missing_threshold_action = "skip"
)
scores_manual_table <- format_scores_table(scores_manual, df_markers2)

# "Well aligned" in the published Table S3 is the formula-positive set
# (prop_pos_gated >= 0.25 & > prop_pos_all; 35 GPs here, matching
# data/CITEseq_alignment_scores_manual.csv) hand-trimmed to those whose protein
# gate and GP-loading gate also agree visually on the MDE embedding -- the 25
# GPs below. We reproduce that curated flag (intersected with the formula set so
# it stays internally consistent if the underlying numbers ever shift). Note
# this 25-GP table set is deliberately distinct from Figure 6b's separately
# curated 27-GP well_aligned_gps in code/R/citeseq_shared_setup.R.
well_aligned_final <- c(
  "GP3", "GP8", "GP10", "GP12", "GP22", "GP25", "GP26", "GP27", "GP29", "GP30",
  "GP32", "GP35", "GP41", "GP58", "GP63", "GP68", "GP77", "GP80", "GP107",
  "GP117", "GP163", "GP166", "GP170", "GP171", "GP181"
)
scores_manual_table[["Well aligned"]] <-
  scores_manual_table[["Well aligned"]] & scores_manual_table$GP %in% well_aligned_final

# Presentation subset used in Table S3, with the two proportion columns given
# their published, more descriptive headers.
protein_gating <- scores_manual_table[, c(
  "GP",
  "Positive markers",
  "Negative markers",
  "Prop. positive (gated)",
  "Prop. positive (all)",
  "Well aligned"
)]
colnames(protein_gating) <- c(
  "GP",
  "Positive markers",
  "Negative markers",
  "Prop. positive among gated (True Discovery Proportion)",
  "Prop. positive among all cells",
  "Well aligned"
)

write.csv(
  protein_gating,
  file = paste0(output_path, "ExtendedDataTable7_protein_gating.csv"),
  row.names = FALSE
)

Table

Showing the first 20 rows (of 200), ordered well-aligned GPs first; download the full table at figures/generated/ExtendedDataTable7_protein_gating.csv.

GP Positive markers Negative markers Prop. positive among gated (True Discovery Proportion) Prop. positive among all cells Well aligned
GP117 CD73.5NTD, LY49A, CD24 THY1.2, CD44 1.000 0.003 TRUE
GP10 KLRG1, CD8B, CD8A, ITAX.CD11C, ICAM1, ITA4.CD49D, CD29 CD4, CD62L, CD5 0.988 0.042 TRUE
GP26 CD8B, CD38, CD44, CD86, CD8A, CD29, CD39, CD11A CD45RB, CD62L 0.985 0.306 TRUE
GP68 IL2RA.CD25, FR4, GITR.CD357, NEUROPILIN1.CD304 0.982 0.057 TRUE
GP171 CD62L CD44 0.971 0.868 TRUE
GP58 CD8B, CD8A CD4 0.949 0.448 TRUE
GP8 TCRVG3 0.925 0.006 TRUE
GP30 CD11A, CD49B, CD38 CD8B, CD8A, CD4 0.880 0.128 TRUE
GP27 KLRG1, ICOS.CD278, GITR.CD357 0.864 0.035 TRUE
GP170 ITB7, CD103, CD4, CD38 GITR.CD357, CD62L 0.823 0.214 TRUE
GP80 CD29, CD44, ITA4.CD49D ITB7, CD103 0.795 0.398 TRUE
GP35 THY1.2, CD73.5NTD, CD11A, CD2, CD69, CD5, ITAM.CD11B CD62L 0.793 0.313 TRUE
GP12 FR4, CD73.5NTD CD62L, CD45RB 0.752 0.102 TRUE
GP3 THY1.2, CD5, CD2, CD11A, CD44, SCA1 0.746 0.112 TRUE
GP29 CD8A CD4, CD8B 0.725 0.210 TRUE
GP77 CD55.DAF, CD38, CD24, LY49A, B220, ITB7, CD45RB 0.722 0.003 TRUE
GP166 CD44, THY1.2, KLRG1, ITB7, ITAM.CD11B 0.708 0.406 TRUE
GP22 LY49A CD4, CD8B, TCRGD 0.703 0.050 TRUE
GP32 CD45RB, CD27, CD62L CD103, CD24, CD38, ITB7, CD4, CD73.5NTD 0.696 0.548 TRUE
GP25 CD62L, CD45RB, CD55.DAF 0.686 0.334 TRUE

Extended Data Table 7. One row per GP: its curated positive / negative protein marker signature, and how well a protein gate built from that signature recovers cells with high GP loading. For each GP, cells are gated by its markers (positive markers above their threshold, negative at/below); we report the proportion of gated cells positive for the GP (loading > 0.1; the True Discovery Proportion) versus that proportion among all cells, and a Well aligned flag. The flag is the formula-positive set (TDP >= 0.25 and greater than the all-cell proportion) hand-trimmed to those whose protein and loading gates also agree visually on the MDE embedding – reproducing the published table’s curated 25-GP set.


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: Asia/Tokyo
tzcode source: internal

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

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  evaluate_1.0.5  jquerylib_0.1.4 tibble_3.3.0   
[21] fastmap_1.2.0   yaml_2.3.12     lifecycle_1.0.5 stringr_1.6.0  
[25] compiler_4.5.1  fs_1.6.6        Rcpp_1.1.1-1.1  pkgconfig_2.0.3
[29] later_1.4.4     digest_0.6.39   R6_2.6.1        pillar_1.11.1  
[33] magrittr_2.0.5  bslib_0.9.0     tools_4.5.1     cachem_1.1.0