Last updated: 2022-05-27

Checks: 6 1

Knit directory: synovialscrnaseq/

This reproducible R Markdown analysis was created with workflowr (version 1.6.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 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.

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(20210105) 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 0f8368f. 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:    '/
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    .empty/
    Ignored:    analysis/.Rhistory
    Ignored:    analysis/iSEE_interactive_document.html
    Ignored:    code/test_files/
    Ignored:    data/Culemann/
    Ignored:    data/E-MTAB-8322/
    Ignored:    data/Synovial scRNA-seq samples - Sheet1.csv
    Ignored:    data/Zhang_top20_singlecell_cluster_markers_fromGithub.csv
    Ignored:    data/findMarkers_results.rds
    Ignored:    data/findMarkers_results_v2.rds
    Ignored:    data/info/
    Ignored:    data/syn_sce_tidy_filtered.rds
    Ignored:    data/syn_sce_tidy_hvg.rds
    Ignored:    data/syn_sce_tidy_hvg_cms.rds
    Ignored:    docs/
    Ignored:    output/Figures_Paper/
    Ignored:    output/Sample_summaries_RA_comparisons.rds
    Ignored:    output/Sample_summaries_direct_dissociation.rds
    Ignored:    output/Sample_summaries_exvivo_treatment.rds
    Ignored:    output/count_matrix_unfiltered.mtx
    Ignored:    output/emptyDrops_result_v4.rds
    Ignored:    output/emptyDrops_result_v4_tmp.rds
    Ignored:    output/entropies_fstat_v4.rds
    Ignored:    output/entropies_fstat_v4_ec.rds
    Ignored:    output/entropies_fstat_v4_main.rds
    Ignored:    output/entropies_fstat_v4_mp.rds
    Ignored:    output/entropies_fstat_v4_sf.rds
    Ignored:    output/entropies_fstat_v4_tc.rds
    Ignored:    output/entropies_fstat_v5_ec.rds
    Ignored:    output/entropies_fstat_v5_main.rds
    Ignored:    output/entropies_fstat_v5_mp.rds
    Ignored:    output/entropies_fstat_v5_sf.rds
    Ignored:    output/entropies_fstat_v5_tc.rds
    Ignored:    output/findMarkers_results_v4.rds
    Ignored:    output/findMarkers_results_v4_ec.rds
    Ignored:    output/findMarkers_results_v4_main.rds
    Ignored:    output/findMarkers_results_v4_mp.rds
    Ignored:    output/findMarkers_results_v4_sf.rds
    Ignored:    output/findMarkers_results_v4_tc.rds
    Ignored:    output/findMarkers_results_v5_ec.rds
    Ignored:    output/findMarkers_results_v5_main.rds
    Ignored:    output/findMarkers_results_v5_mp.rds
    Ignored:    output/findMarkers_results_v5_sf.rds
    Ignored:    output/findMarkers_results_v5_tc.rds
    Ignored:    output/findMarkers_results_v6.rds
    Ignored:    output/findMarkers_results_v6_ec.rds
    Ignored:    output/findMarkers_results_v6_main.rds
    Ignored:    output/findMarkers_results_v6_mp.rds
    Ignored:    output/findMarkers_results_v6_sf.rds
    Ignored:    output/findMarkers_results_v6_tc.rds
    Ignored:    output/goana_results_v6_ec.rds
    Ignored:    output/goana_results_v6_mp.rds
    Ignored:    output/syn_v4/
    Ignored:    output/syn_v4_clustering_lookup.rds
    Ignored:    output/syn_v4_clustering_lookup_invivo.rds
    Ignored:    output/syn_v4_conos_obj.rds
    Ignored:    output/syn_v4_neiprop.rds
    Ignored:    output/syn_v4_neiprop_invivo.rds
    Ignored:    output/syn_v4_predref.rds
    Ignored:    output/syn_v4_predref_invivo.rds
    Ignored:    output/syn_v4_res_da_1.rds
    Ignored:    output/syn_v4_res_da_2.rds
    Ignored:    output/syn_v4_res_da_2_Accute_inflammation.rds
    Ignored:    output/syn_v4_res_da_2_Diagnosis.rds
    Ignored:    output/syn_v4_res_da_2_Diagnosis_main.rds
    Ignored:    output/syn_v4_res_da_2_Lymphoid_folicles.rds
    Ignored:    output/syn_v4_res_da_2_Pathotype.rds
    Ignored:    output/syn_v4_res_da_2_Sample_prep.rds
    Ignored:    output/syn_v4_res_da_2_Therapy.rds
    Ignored:    output/syn_v4_res_da_2_Treatment.rds
    Ignored:    output/syn_v4_res_da_2_Vascularisation_bin.rds
    Ignored:    output/syn_v4_res_da_Accute_inflammation_invivo.rds
    Ignored:    output/syn_v4_res_da_Diagnosis_invivo.rds
    Ignored:    output/syn_v4_res_da_Diagnosis_main_invivo.rds
    Ignored:    output/syn_v4_res_da_Lymphoid_folicles_invivo.rds
    Ignored:    output/syn_v4_res_da_Pathotype_invivo.rds
    Ignored:    output/syn_v4_res_da_Therapy_invivo.rds
    Ignored:    output/syn_v4_res_da_Vascularisation_bin_invivo.rds
    Ignored:    output/syn_v4_res_ds_2.rds
    Ignored:    output/syn_v4_res_ds_2_Accute_inflammation.rds
    Ignored:    output/syn_v4_res_ds_2_Diagnosis.rds
    Ignored:    output/syn_v4_res_ds_2_Diagnosis_main.rds
    Ignored:    output/syn_v4_res_ds_2_Lymphoid_folicles.rds
    Ignored:    output/syn_v4_res_ds_2_Pathotype.rds
    Ignored:    output/syn_v4_res_ds_2_Sample_prep.rds
    Ignored:    output/syn_v4_res_ds_2_Therapy.rds
    Ignored:    output/syn_v4_res_ds_2_Treatment.rds
    Ignored:    output/syn_v4_res_ds_2_Vascularisation_bin.rds
    Ignored:    output/syn_v4_res_ds_Accute_inflammation_invivo.rds
    Ignored:    output/syn_v4_res_ds_Diagnosis_invivo.rds
    Ignored:    output/syn_v4_res_ds_Diagnosis_main_invivo.rds
    Ignored:    output/syn_v4_res_ds_Lymphoid_folicles_invivo.rds
    Ignored:    output/syn_v4_res_ds_Pathotype_invivo.rds
    Ignored:    output/syn_v4_res_ds_Therapy_invivo.rds
    Ignored:    output/syn_v4_res_ds_Vascularisation_bin_invivo.rds
    Ignored:    output/syn_v4_sce.rds
    Ignored:    output/syn_v4_sce_annot_df_invivo.csv
    Ignored:    output/syn_v4_sce_annot_df_invivo.rds
    Ignored:    output/syn_v4_sce_conos.rds
    Ignored:    output/syn_v4_sce_ec.rds
    Ignored:    output/syn_v4_sce_ec_invivo.rds
    Ignored:    output/syn_v4_sce_emptyDrops_filt_invivo.rds
    Ignored:    output/syn_v4_sce_emptyDrops_invivo.rds
    Ignored:    output/syn_v4_sce_filtered.rds
    Ignored:    output/syn_v4_sce_filtered_invivo.rds
    Ignored:    output/syn_v4_sce_hdf5/
    Ignored:    output/syn_v4_sce_hvg.rds
    Ignored:    output/syn_v4_sce_hvg_cms.rds
    Ignored:    output/syn_v4_sce_hvg_cms_doublet.rds
    Ignored:    output/syn_v4_sce_hvg_cms_doublet_annot.rds
    Ignored:    output/syn_v4_sce_hvg_cms_doublet_annot_RA_only.rds
    Ignored:    output/syn_v4_sce_hvg_cms_doublet_annot_invivo.rds
    Ignored:    output/syn_v4_sce_hvg_cms_doublet_annot_manual_invivo.rds
    Ignored:    output/syn_v4_sce_hvg_cms_doublet_invivo.rds
    Ignored:    output/syn_v4_sce_hvg_invivo.rds
    Ignored:    output/syn_v4_sce_mp.rds
    Ignored:    output/syn_v4_sce_mp_invivo.rds
    Ignored:    output/syn_v4_sce_sf.rds
    Ignored:    output/syn_v4_sce_sf_invivo.rds
    Ignored:    output/syn_v4_sce_tc.rds
    Ignored:    output/syn_v4_sce_tc_invivo.rds
    Ignored:    output/syn_v4_swappedDrops_24300_after.rds
    Ignored:    output/syn_v4_swappedDrops_24300_before.rds
    Ignored:    output/syn_v4_swappedDrops_24555_before.rds
    Ignored:    output/syn_v4_swappedDrops_24793_after.rds
    Ignored:    output/syn_v4_swappedDrops_24793_before.rds
    Ignored:    output/syn_v4_swappedDrops_after.rds
    Ignored:    output/syn_v4_swappedDrops_before.rds
    Ignored:    output/syn_v5_annot_df_manual.rds
    Ignored:    output/syn_v5_cluster_cellid_match_invivo.rds
    Ignored:    output/syn_v5_clustering_lookup_invivo.rds
    Ignored:    output/syn_v5_clustering_lookup_multiple_invivo.rds
    Ignored:    output/syn_v5_res_da_Accute_inflammation_invivo.rds
    Ignored:    output/syn_v5_res_da_Diagnosis_invivo.rds
    Ignored:    output/syn_v5_res_da_Diagnosis_main_invivo.rds
    Ignored:    output/syn_v5_res_da_Lymphoid_folicles_invivo.rds
    Ignored:    output/syn_v5_res_da_Pathotype_invivo.rds
    Ignored:    output/syn_v5_res_da_Therapy_invivo.rds
    Ignored:    output/syn_v5_res_da_Vascularisation_bin_invivo.rds
    Ignored:    output/syn_v5_res_ds_Accute_inflammation_invivo.rds
    Ignored:    output/syn_v5_res_ds_Diagnosis_invivo.rds
    Ignored:    output/syn_v5_res_ds_Diagnosis_main_invivo.rds
    Ignored:    output/syn_v5_res_ds_Lymphoid_folicles_invivo.rds
    Ignored:    output/syn_v5_res_ds_Pathotype_invivo.rds
    Ignored:    output/syn_v5_res_ds_Therapy_invivo.rds
    Ignored:    output/syn_v5_res_ds_Vascularisation_bin_invivo.rds
    Ignored:    output/syn_v5_sce.rds
    Ignored:    output/syn_v5_sce_ec_invivo.rds
    Ignored:    output/syn_v5_sce_filtered_invivo.rds
    Ignored:    output/syn_v5_sce_hdf5/
    Ignored:    output/syn_v5_sce_hvg_cms_doublet_annot_manual_invivo.rds
    Ignored:    output/syn_v5_sce_hvg_cms_doublet_cmstest_invivo.rds
    Ignored:    output/syn_v5_sce_hvg_cms_doublet_invivo.rds
    Ignored:    output/syn_v5_sce_hvg_cms_doublet_subcluster_invivo.rds
    Ignored:    output/syn_v5_sce_hvg_invivo.rds
    Ignored:    output/syn_v5_sce_mp_invivo.rds
    Ignored:    output/syn_v5_sce_sf_invivo.rds
    Ignored:    output/syn_v5_sce_tc_invivo.rds
    Ignored:    output/syn_v5_vst_out_invivo.rds
    Ignored:    output/syn_v6_cluster_cellid_match_invivo.rds
    Ignored:    output/syn_v6_clustering_lookup_invivo.rds
    Ignored:    output/syn_v6_clustering_lookup_multiple_invivo.rds
    Ignored:    output/syn_v6_sce.rds
    Ignored:    output/syn_v6_sce_ec_invivo.rds
    Ignored:    output/syn_v6_sce_filtered_invivo.rds
    Ignored:    output/syn_v6_sce_hdf5/
    Ignored:    output/syn_v6_sce_hvg_cms_doublet_invivo.rds
    Ignored:    output/syn_v6_sce_hvg_cms_doublet_subcluster_invivo.rds
    Ignored:    output/syn_v6_sce_hvg_invivo.rds
    Ignored:    output/syn_v6_sce_hvg_marker_genes.rds
    Ignored:    output/syn_v6_sce_mp_invivo.rds
    Ignored:    output/syn_v6_sce_sf_invivo.rds
    Ignored:    output/syn_v6_sce_tc_invivo.rds
    Ignored:    output/syn_v6_sfig1.rds
    Ignored:    output/syn_v6_vst_out_invivo.rds

Untracked files:
    Untracked:  analysis/test.Rmd
    Untracked:  code/rebuild_ezRun.R
    Untracked:  nonhosted_public/
    Untracked:  singRstudio.sh.bak

Unstaged changes:
    Modified:   analysis/scRNAseq_complete_04-2_celltype_markers_subcelltypes.Rmd
    Modified:   analysis/scRNAseq_complete_04_Annotation_v6.Rmd
    Modified:   analysis/scRNAseq_complete_Figures.Rmd
    Modified:   data/syn_sce_tidy_hvg_cms_doublet.rds

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/scRNAseq_complete_04_Annotation_v6.Rmd) and HTML (public/scRNAseq_complete_04_Annotation_v6.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 3443cc6 Reto Gerber 2022-04-25 Update
html 3443cc6 Reto Gerber 2022-04-25 Update
Rmd b5b139f Reto Gerber 2022-03-29 Update analysis
html b5b139f Reto Gerber 2022-03-29 Update analysis
Rmd 7d99571 Reto Gerber 2022-03-21 update analysis
html 7d99571 Reto Gerber 2022-03-21 update analysis

Set up

suppressPackageStartupMessages({
  library(magrittr)
  library(SingleCellExperiment)
})
n_workers <- 10
RhpcBLASctl::blas_set_num_threads(n_workers)

analysis_version <- 6
remove_low_quality_samples <- TRUE

here::here()
[1] "/home/retger/Synovial/synovialscrnaseq"
set.seed(100)

clusters_lookup <- list()
sce_main <- readRDS(file =here::here("output",paste0("syn_v",analysis_version,"_sce_hvg_cms_doublet_subcluster_invivo.rds")))
sce_main$Diagnosis_main[sce_main$Sample%in%c("Syn_Bio_078","Syn_Bio_091","Syn_Bio_099")] <- "Undiff. Arthritis"
Loading required package: tidySingleCellExperiment

Attaching package: 'tidySingleCellExperiment'
The following object is masked from 'package:IRanges':

    slice
The following object is masked from 'package:S4Vectors':

    rename
The following object is masked from 'package:matrixStats':

    count
The following object is masked from 'package:magrittr':

    extract
The following object is masked from 'package:stats':

    filter

Annotation main celltypes

sce_main$main_celltype <- as.integer(sce_main$kgraph_clusters)
sce_main$main_celltype[sce_main$main_celltype %in% c(1,6,13,19,22)] <- "T cells/NK cells"
sce_main$main_celltype[sce_main$main_celltype %in% c(11,14)] <- "Endothelial cells"
sce_main$main_celltype[sce_main$main_celltype %in% c(4,8,9,16)] <- "Fibroblasts"
sce_main$main_celltype[sce_main$main_celltype %in% c(2,17,18,21,23,5)] <- "Macrophages"
sce_main$main_celltype[sce_main$main_celltype %in% c(15)] <- "Dendritic cells"
sce_main$main_celltype[sce_main$main_celltype %in% c(7)] <- "Neutrophils"
sce_main$main_celltype[sce_main$main_celltype %in% c(20)] <- "B cells"
sce_main$main_celltype[sce_main$main_celltype %in% c(3)] <- "Mast cells"
sce_main$main_celltype[sce_main$main_celltype %in% c(12)] <- "Plasmablasts"
sce_main$main_celltype[sce_main$main_celltype %in% c(24)] <- "Pericytes/Mural cells"
sce_main$main_celltype[sce_main$main_celltype %in% c(10)] <- "Plasmacytoid DCs"

Annotation SF

celltype_name_pre <- "sf"
tmpfilename <- paste0("syn_v",analysis_version,"_sce_",celltype_name_pre,dplyr::if_else(remove_low_quality_samples, "_invivo",""),".rds")
sce_sub <- readRDS(file = here::here("output",tmpfilename))
sce_sub$sf_clusters_final <- as.integer(sce_sub$sf_clusters)
sce_sub$sf_celltype <- as.integer(sce_sub$sf_clusters_final)

# sce_sub$sf_celltype[sce_sub$sf_celltype %in% c(1)] <- "VCAN+CXCL14+ Sublining"
# sce_sub$sf_celltype[sce_sub$sf_celltype %in% c(2)] <- "LOXL2+SERPINE1+ Lining"
# sce_sub$sf_celltype[sce_sub$sf_celltype %in% c(3)] <- "POSTN+ASPN+ Transitional"
# sce_sub$sf_celltype[sce_sub$sf_celltype %in% c(4)] <- "SAA1+SAA2+ Lining"
# sce_sub$sf_celltype[sce_sub$sf_celltype %in% c(5)] <- "MMP3+FN+ Lining"
# sce_sub$sf_celltype[sce_sub$sf_celltype %in% c(6)] <- "TNXB+IGFBP6+ Transitional"
# sce_sub$sf_celltype[sce_sub$sf_celltype %in% c(7)] <- "POSTN+SFRP2+ Sublining"
# sce_sub$sf_celltype[sce_sub$sf_celltype %in% c(8)] <- "CHI3L2+CRTAC1+ Lining"

sce_sub$sf_celltype[sce_sub$sf_celltype %in% c(1)] <- "GGT5high CXCL12high FGF7+"
sce_sub$sf_celltype[sce_sub$sf_celltype %in% c(2)] <- "SERPINE1 + COL5A3+"
sce_sub$sf_celltype[sce_sub$sf_celltype %in% c(3)] <- "CADM1high ACAN+"
sce_sub$sf_celltype[sce_sub$sf_celltype %in% c(4)] <- "SCD4+ SAA1+ SAA2+"
sce_sub$sf_celltype[sce_sub$sf_celltype %in% c(5)] <- "CLIC5+  HBEGF+"
sce_sub$sf_celltype[sce_sub$sf_celltype %in% c(6)] <- "TNXBhigh GFBP6+ FGFBP2+"
sce_sub$sf_celltype[sce_sub$sf_celltype %in% c(7)] <- "NOTCH3+ GGT5low"
sce_sub$sf_celltype[sce_sub$sf_celltype %in% c(8)] <- "HLA-DRAhigh"

clusters_lookup[[celltype_name_pre]] <- data.frame(cell_id = colnames(sce_sub), 
                                                   cluster = sce_sub[["sf_celltype"]])
tmpfilename <- paste0("syn_v",analysis_version,"_sce_",celltype_name_pre,dplyr::if_else(remove_low_quality_samples, "_invivo",""),".rds")
saveRDS(sce_sub, file = here::here("output",tmpfilename))

Annotation MP

celltype_name_pre <- "mp"
tmpfilename <- paste0("syn_v",analysis_version,"_sce_",celltype_name_pre,dplyr::if_else(remove_low_quality_samples, "_invivo",""),".rds")
sce_sub <- readRDS(file = here::here("output",tmpfilename))
sce_sub$mp_clusters_final <- as.integer(sce_sub$mp_clusters)
sce_sub$mp_clusters_final[sce_sub$mp_clusters_final == 7 & sce_sub$mp_clusters_walktrap_k10 %in% c(10,13,14)] <- max(sce_sub$mp_clusters_final)+1
sce_sub$mp_clusters_final[sce_sub$mp_clusters_final == 7 & sce_sub$mp_clusters_walktrap_k10 %in% c(16)] <- max(sce_sub$mp_clusters_final)+1

sce_sub$mp_celltype <- as.integer(sce_sub$mp_clusters_final)
sce_sub$mp_celltype[sce_sub$mp_celltype %in% c(1)] <- "TIMD4- TREM2- LYVE1high CD209high"
sce_sub$mp_celltype[sce_sub$mp_celltype %in% c(2)] <- "CLEC9A+ CADM1+ CLNK+"
sce_sub$mp_celltype[sce_sub$mp_celltype %in% c(3)] <- "CX3CR1+ CD48high CD52high S100A12+"
sce_sub$mp_celltype[sce_sub$mp_celltype %in% c(4)] <- "TIMD4+ TREM2+ LYVE1low IGF1-"
sce_sub$mp_celltype[sce_sub$mp_celltype %in% c(5)] <- "TIMD4+ TREM2+ LYVE1low EGR1-"
sce_sub$mp_celltype[sce_sub$mp_celltype %in% c(6)] <- "LILRA4+ GZMB+ ITM2C+ plasmacytoid"
sce_sub$mp_celltype[sce_sub$mp_celltype %in% c(7)] <- "CX3CR1+ CD48low CLEC10A+"
sce_sub$mp_celltype[sce_sub$mp_celltype %in% c(8)] <- "TIMD4+ TREM2+ LYVE1med"
sce_sub$mp_celltype[sce_sub$mp_celltype %in% c(9)] <- "COLEC12- transitional"
sce_sub$mp_celltype[sce_sub$mp_celltype %in% c(10)] <- "CX3CR1- SPP1+ TREM2+"
sce_sub$mp_celltype[sce_sub$mp_celltype %in% c(11)] <- "FOL2R+ MERTK- CD206-"
sce_sub$mp_celltype[sce_sub$mp_celltype %in% c(12)] <- "CD1C+ CLEC10A+"
sce_sub$mp_celltype[sce_sub$mp_celltype %in% c(13)] <- "LAMP3+ IDO1+"


clusters_lookup[[celltype_name_pre]] <- data.frame(cell_id = colnames(sce_sub), 
                                                   cluster = sce_sub[["mp_celltype"]])
tmpfilename <- paste0("syn_v",analysis_version,"_sce_",celltype_name_pre,dplyr::if_else(remove_low_quality_samples, "_invivo",""),".rds")
saveRDS(sce_sub, file = here::here("output",tmpfilename))

Annotation EC

celltype_name_pre <- "ec"
tmpfilename <- paste0("syn_v",analysis_version,"_sce_",celltype_name_pre,dplyr::if_else(remove_low_quality_samples, "_invivo",""),".rds")
sce_sub <- readRDS(file = here::here("output",tmpfilename))
sce_sub$ec_clusters_final <- as.integer(sce_sub$ec_clusters)
sce_sub$ec_celltype <- as.integer(sce_sub$ec_clusters_final)
sce_sub$ec_celltype[sce_sub$ec_celltype %in% c(1)] <- "PROX1+ LYVE1+ CCL21+ lymphatic ECs"
sce_sub$ec_celltype[sce_sub$ec_celltype %in% c(2)] <- "TOP2A+ CENPF+ MKI67+ ECs"
sce_sub$ec_celltype[sce_sub$ec_celltype %in% c(3)] <- "GJA4+ CLDN5+ arterial ECs"
sce_sub$ec_celltype[sce_sub$ec_celltype %in% c(4)] <- "SPP1+ KDR+ capillary ECs"
sce_sub$ec_celltype[sce_sub$ec_celltype %in% c(5)] <- "ACKR1high VWFhigh SELE+ IL6+ venous ECs"
sce_sub$ec_celltype[sce_sub$ec_celltype %in% c(6)] <- "ACKR1high VWFhigh SELE+ IL6- venous ECs"
sce_sub$ec_celltype[sce_sub$ec_celltype %in% c(7)] <- "ACKR1med KDRlow SPARChigh ECs"
sce_sub$ec_celltype[sce_sub$ec_celltype %in% c(8)] <- "ACKR1high VWFhigh SELE+ CCL2+ TNFAIP3+ venous ECs"

clusters_lookup[[celltype_name_pre]] <- data.frame(cell_id = colnames(sce_sub), 
                                                   cluster = sce_sub[["ec_celltype"]])
tmpfilename <- paste0("syn_v",analysis_version,"_sce_",celltype_name_pre,dplyr::if_else(remove_low_quality_samples, "_invivo",""),".rds")
saveRDS(sce_sub, file = here::here("output",tmpfilename))

Annotation TC

celltype_name_pre <- "tc"
tmpfilename <- paste0("syn_v",analysis_version,"_sce_",celltype_name_pre,dplyr::if_else(remove_low_quality_samples, "_invivo",""),".rds")
sce_sub <- readRDS(file = here::here("output",tmpfilename))
sce_sub$tc_clusters_final <- as.integer(sce_sub$tc_clusters)
sce_sub$tc_celltype <- as.integer(sce_sub$tc_clusters_final)
# sce_sub$tc_celltype[sce_sub$tc_celltype %in% c(1)] <- "CD4+CCR7+ Naive T Cells"
# sce_sub$tc_celltype[sce_sub$tc_celltype %in% c(2)] <- "CD8+CCR7+ Naive T Cells"
# sce_sub$tc_celltype[sce_sub$tc_celltype %in% c(3)] <- "FOX3+CTLA4+ Tregs"
# sce_sub$tc_celltype[sce_sub$tc_celltype %in% c(4)] <- "NCAM+KLRC1+ NK Cells"
# sce_sub$tc_celltype[sce_sub$tc_celltype %in% c(5)] <- "CD4+CCR6+ T Helper Cells"
# sce_sub$tc_celltype[sce_sub$tc_celltype %in% c(6)] <- "CD4+IL7R+ T Helper Cells"
# sce_sub$tc_celltype[sce_sub$tc_celltype %in% c(7)] <- "CD8+GZM+ Cytotoxic T cells"

sce_sub$tc_celltype[sce_sub$tc_celltype %in% c(1)] <- "CCR7high LEFFhigh SELLhigh"
sce_sub$tc_celltype[sce_sub$tc_celltype %in% c(2)] <- "NKG7low GZMK+"
sce_sub$tc_celltype[sce_sub$tc_celltype %in% c(3)] <- "FOXP3+ CXCL13+ PDCD1+"
sce_sub$tc_celltype[sce_sub$tc_celltype %in% c(4)] <- "CD3- NKG7high GNLYhigh NK cells"
sce_sub$tc_celltype[sce_sub$tc_celltype %in% c(5)] <- "CCR7med LEFFmed SELLmed"
sce_sub$tc_celltype[sce_sub$tc_celltype %in% c(6)] <- " CCR7low/- LEFFlow SELL-"
sce_sub$tc_celltype[sce_sub$tc_celltype %in% c(7)] <- "NKG7+ GNLY+/- GZMKhigh/low"


# remove cluster 8
sce_sub <- sce_sub[,sce_sub$tc_celltype != 8]
Loading required package: BiocSingular
clusters_lookup[[celltype_name_pre]] <- data.frame(cell_id = colnames(sce_sub), 
                                                   cluster = sce_sub[["tc_celltype"]])
tmpfilename <- paste0("syn_v",analysis_version,"_sce_",celltype_name_pre,dplyr::if_else(remove_low_quality_samples, "_invivo",""),".rds")
saveRDS(sce_sub, file = here::here("output",tmpfilename))
colData(sce_main)$minor_celltype <- colData(sce_main)$main_celltype

names(clusters_lookup)
[1] "sf" "mp" "ec" "tc"
for(sub_name in names(clusters_lookup)){
  celllabelmatch <- match(clusters_lookup[[sub_name]]$cell_id,
                        colnames(sce_main))
  print(table(is.na(celllabelmatch)))
  celllabelmatch <- celllabelmatch[!is.na(celllabelmatch)]
  colData(sce_main)$minor_celltype[celllabelmatch] <-  clusters_lookup[[sub_name]]$cluster
}

FALSE 
30843 

FALSE 
36419 

FALSE 
 9560 

FALSE 
24047 
saveRDS(sce_main, file =here::here("output",paste0("syn_v",analysis_version,"_sce_hvg_cms_doublet_subcluster_invivo.rds")))

sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04 LTS

Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       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=C             
 [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] parallel  stats4    stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
 [1] BiocSingular_1.6.0             tidySingleCellExperiment_1.0.0
 [3] SingleCellExperiment_1.12.0    SummarizedExperiment_1.20.0   
 [5] Biobase_2.50.0                 GenomicRanges_1.42.0          
 [7] GenomeInfoDb_1.26.7            IRanges_2.24.1                
 [9] S4Vectors_0.28.1               BiocGenerics_0.36.1           
[11] MatrixGenerics_1.2.1           matrixStats_0.58.0            
[13] magrittr_2.0.1                 workflowr_1.6.2               

loaded via a namespace (and not attached):
 [1] rsvd_1.0.3             Rcpp_1.0.6             here_1.0.1            
 [4] lattice_0.20-41        tidyr_1.1.2            assertthat_0.2.1      
 [7] rprojroot_2.0.2        digest_0.6.27          RhpcBLASctl_0.20-137  
[10] R6_2.5.0               evaluate_0.14          httr_1.4.2            
[13] ggplot2_3.3.3          pillar_1.4.7           zlibbioc_1.36.0       
[16] rlang_0.4.10           lazyeval_0.2.2         irlba_2.3.3           
[19] data.table_1.13.6      whisker_0.4            Matrix_1.3-2          
[22] rmarkdown_2.6          BiocParallel_1.24.1    stringr_1.4.0         
[25] htmlwidgets_1.5.3      beachmat_2.6.4         RCurl_1.98-1.2        
[28] munsell_0.5.0          DelayedArray_0.16.3    compiler_4.0.3        
[31] httpuv_1.5.5           xfun_0.21              pkgconfig_2.0.3       
[34] htmltools_0.5.1.1      tidyselect_1.1.0       tibble_3.0.6          
[37] GenomeInfoDbData_1.2.4 viridisLite_0.3.0      fansi_0.4.2           
[40] crayon_1.4.1           dplyr_1.0.4            later_1.1.0.1         
[43] bitops_1.0-6           grid_4.0.3             jsonlite_1.7.2        
[46] gtable_0.3.0           lifecycle_1.0.0        DBI_1.1.1             
[49] git2r_0.28.0           scales_1.1.1           cli_2.3.0             
[52] stringi_1.5.3          XVector_0.30.0         fs_1.5.0              
[55] promises_1.2.0.1       ellipsis_0.3.1         generics_0.1.0        
[58] vctrs_0.3.6            tools_4.0.3            glue_1.4.2            
[61] purrr_0.3.4            yaml_2.2.1             colorspace_2.0-0      
[64] plotly_4.9.3           knitr_1.31