From c95d5e11909b19b553fdfacdca9d5ccac7dbf444 Mon Sep 17 00:00:00 2001 From: Dharmesh Bhuva Date: Thu, 28 Nov 2024 14:53:57 +1030 Subject: [PATCH 1/2] remove duplicate package imports --- DESCRIPTION | 5 ----- 1 file changed, 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index ea2b33e..715ca53 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -60,15 +60,10 @@ Imports: future.apply, ids, RColorBrewer, - digest, - cowplot, - igraph, reshape2, - callr, future, methods, pbapply, - reshape2, scales, data.table, ggplot2, From fa5f150ff69207c7adca482680ec5f76bb7497f5 Mon Sep 17 00:00:00 2001 From: Dharmesh Bhuva Date: Mon, 16 Dec 2024 10:38:02 +1030 Subject: [PATCH 2/2] Added code to compute the mapping and added data required for mapping. --- R/HPCell.R | 7 + R/functions_consensus.R | 134 +++++ data/celltype_unification_maps.rda | Bin 0 -> 6979 bytes data/immune_graph.rda | Bin 0 -> 762 bytes data/nonimmune_cellxgene.rda | Bin 0 -> 252 bytes inst/extdata/immune_map_azimuth.csv | 30 ++ inst/extdata/immune_map_blueprint.csv | 45 ++ inst/extdata/immune_map_cellxgene.csv | 679 ++++++++++++++++++++++++++ inst/extdata/immune_map_monaco.csv | 38 ++ inst/extdata/immune_tree.csv | 38 ++ inst/scripts/build_graph.R | 12 + inst/scripts/build_unification_maps.R | 41 ++ inst/scripts/example_run.R | 36 ++ 13 files changed, 1060 insertions(+) create mode 100644 R/HPCell.R create mode 100644 R/functions_consensus.R create mode 100644 data/celltype_unification_maps.rda create mode 100644 data/immune_graph.rda create mode 100644 data/nonimmune_cellxgene.rda create mode 100755 inst/extdata/immune_map_azimuth.csv create mode 100755 inst/extdata/immune_map_blueprint.csv create mode 100755 inst/extdata/immune_map_cellxgene.csv create mode 100755 inst/extdata/immune_map_monaco.csv create mode 100755 inst/extdata/immune_tree.csv create mode 100644 inst/scripts/build_graph.R create mode 100644 inst/scripts/build_unification_maps.R create mode 100644 inst/scripts/example_run.R diff --git a/R/HPCell.R b/R/HPCell.R new file mode 100644 index 0000000..eca676c --- /dev/null +++ b/R/HPCell.R @@ -0,0 +1,7 @@ +.myDataEnv <- new.env(parent = emptyenv()) # not exported + +.data_internal <- function(dataset) { + if (!exists(dataset, envir = .myDataEnv)) { + utils::data(list = c(dataset), envir = .myDataEnv) + } +} \ No newline at end of file diff --git a/R/functions_consensus.R b/R/functions_consensus.R new file mode 100644 index 0000000..e8867dd --- /dev/null +++ b/R/functions_consensus.R @@ -0,0 +1,134 @@ +ensemble_annotation <- function(celltype_matrix, method_weights = NULL, override_celltype = c(), celltype_tree = NULL) { + if (is.null(celltype_tree)) { + .data_internal(immune_graph) + } + + stopifnot(is(celltype_tree, "igraph")) + stopifnot(igraph::is_directed(celltype_tree)) + stopifnot(is.matrix(celltype_matrix) | is.data.frame(celltype_matrix)) + + node_names = igraph::V(celltype_tree)$name + + # check override_celltype nodes are present + missing_nodes = setdiff(override_celltype, node_names) + if (!is.null(missing_nodes) & length(missing_nodes) > 0) { + missing_nodes = paste(missing_nodes, collapse = ", ") + stop(sprintf("the following nodes in 'override_celltype' not found in 'celltype_tree': %s", utils::capture.output(utils::str(missing_nodes)))) + } + + # check celltype_matrix + if (ncol(celltype_matrix) == 1) { + # no ensemble required + return(celltype_matrix) + } else { + celltype_matrix = as.matrix(celltype_matrix) + invalid_types = setdiff(celltype_matrix, c(node_names, NA)) + if (length(invalid_types) > 0) { + warning(sprintf("the following cell types in 'celltype_matrix' are not in the graph and will be set to NA:\n"), utils::capture.output(utils::str(invalid_types))) + } + celltype_matrix[celltype_matrix %in% invalid_types] = NA + } + + # check method_weights + if (is.null(method_weights)) { + method_weights = matrix(1, ncol = ncol(celltype_matrix), nrow = nrow(celltype_matrix)) + } else if (is.vector(method_weights)) { + if (ncol(celltype_matrix) != length(method_weights)) { + stop("the number of columns in 'celltype_matrix' should match the length of 'method_weights'") + } + method_weights = matrix(rep(method_weights, each = nrow(celltype_matrix)), nrow = nrow(celltype_matrix)) + } else if (is.matrix(method_weights) | is.data.frame(method_weights)) { + if (ncol(celltype_matrix) != ncol(method_weights)) { + stop("the number of columns in 'celltype_matrix' and 'method_weights' should be equal") + } + method_weights = as.matrix(method_weights) + } + method_weights = method_weights / rowSums(method_weights) + + # create vote matrix + vote_matrix = Matrix::sparseMatrix(i = integer(0), j = integer(0), dims = c(nrow(celltype_matrix), length(node_names)), dimnames = list(rownames(celltype_matrix), node_names)) + for (i in seq_len(ncol(celltype_matrix))) { + locmat = cbind(seq_len(nrow(celltype_matrix)), as.numeric(factor(celltype_matrix[, i], levels = node_names))) + missing = is.na(locmat[, 2]) + vote_matrix[locmat[!missing, ]] = vote_matrix[locmat[!missing, ]] + method_weights[!missing, i] + } + + # propagate vote to children + d = apply(!is.infinite(igraph::distances(celltype_tree, mode = "out")), 2, as.numeric) + d = as(d, "sparseMatrix") + vote_matrix_children = Matrix::tcrossprod(vote_matrix, Matrix::t(d)) + + # propagate vote to parent + d = igraph::distances(celltype_tree, mode = "in") + d = 1 / (2^d) - 0.1 # vote halved at each subsequent ancestor + diag(d)[igraph::degree(celltype_tree, mode = "in") > 0 & igraph::degree(celltype_tree, mode = "out") == 0] = 0 + diag(d) = diag(d) * 0.9 # prevent leaf nodes from being selected when trying to identify upstream ancestor (works for any number in the interval (0.5, 1)) + vote_matrix_parent = Matrix::tcrossprod(vote_matrix, Matrix::t(d)) + + # assess votes and identify common ancestors for ties + vote_matrix_children = apply(vote_matrix_children, 1, \(x) x[x > 0], simplify = FALSE) + vote_matrix_parent = apply(vote_matrix_parent, 1, \(x) x[x > 0], simplify = FALSE) + ensemble = mapply(\(children, parents) { + # override condition + override_node = intersect(override_celltype, names(children)) + if (length(override_node) > 0) { + return(override_node[1]) + } + + # maximum votes + children = names(children)[children == max(children)] + if (length(children) == 1) { + return(children) + } else { + # lowest ancestor with the maximum votes + parents = names(parents)[parents == max(parents)] + if (length(parents) == 1) { + return(parents) + } else { + return(NA) + } + } + }, vote_matrix_children, vote_matrix_parent) + + return(ensemble) +} + +add_celltype_level <- function(.data, id_col, level = 0, celltype_tree = NULL) { + if (is.null(celltype_tree)) { + .data_internal(immune_graph) + } + stopifnot(is(celltype_tree, "igraph")) + stopifnot(igraph::is_directed(celltype_tree)) + + ig_diameter = igraph::diameter(celltype_tree) + if (level > ig_diameter) { + stop(sprintf("The specified level (%d) exceeds the depth of the celltype tree (%d)", level, ig_diameter)) + } + + # check column exists + id_col_str = rlang::as_string(rlang::ensym(id_col)) + if (!id_col_str %in% colnames(.data)) { + stop(sprintf("Column '%s' not found in .data", rlang::as_string(rlang::ensym(id_col)))) + } + + # generate map + ct_map = igraph::ego(celltype_tree, mode = "in", order = ig_diameter) |> + sapply(\(x) { + x = rev(x$name) + x[min(length(x), level + 1)] + }) |> + setNames(igraph::V(celltype_tree)$name) + + # retain types of the matching level only + d = igraph::distances(celltype_tree, mode = "in") + d[is.infinite(d)] = NA + ct_level = apply(d, 1, max, na.rm = TRUE) + is_child = igraph::degree(celltype_tree, mode = "out") == 0 + ct_map[ct_level[ct_map] != level & !is_child] = NA_character_ + map_df = data.frame(ctypes, ct_map[ctypes]) + colnames(map_df) = c(id_col_str, sprintf("%s_L%d", id_col_str, level)) + + # join and return + .data |> + dplyr::left_join(map_df, copy = TRUE) +} diff --git a/data/celltype_unification_maps.rda b/data/celltype_unification_maps.rda new file mode 100644 index 0000000000000000000000000000000000000000..b7a0a64d8acfb5a026cf61f83904831e303cbc35 GIT binary patch literal 6979 zcmV-J8@%K~T4*^jL0KkKS)gX#H2@zU|I`2f|NsC0|Nnpg{ZPOE|L{Nn0RRLD2mk;B z;37XhxclY}uxYkUbASMS6gd@|;y#17V0rExHmlvL>Sp*ksP*GnO}55yGe*|UHKaDF zqcTw|q`&|O2AXN<0xCv= zYE7u}Pt`p@(@i}?)Bw@yXda-@Xa;~Z8UQrV&;!)L5<&zfL^RPdW|Z1wr|NA?DeX@o z5$b4okb0h@O#pd7W{3k#4NoAODjk5ZZ?Xpvf{pK`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I~pwKXutsjGDxXxPmbN94@vZn8W_jN2&OQhb!S#HN<>JHs<05^(sK s+8ZiwC={VdOr7rmf{$ap*$F>cH&kw_RUC5aUH^-@BAh5lZ6khj0AwX^kN^Mx literal 0 HcmV?d00001 diff --git a/data/nonimmune_cellxgene.rda b/data/nonimmune_cellxgene.rda new file mode 100644 index 0000000000000000000000000000000000000000..4743e3ae4c70194d56df49c84ac79c07e855b15b GIT binary patch literal 252 zcmVqP!vIDzk}@ZiZhR!sJVy#KpfM~MF;-NDMz?$< zLObJ`5#dLpGAE=ivQZWRxX$4jWAQwfX9g+=WJGIPXb3}Lh6u+$i@744C`cSBHBo>Y C%V`k+ literal 0 HcmV?d00001 diff --git a/inst/extdata/immune_map_azimuth.csv b/inst/extdata/immune_map_azimuth.csv new file mode 100755 index 0000000..06b284e --- /dev/null +++ b/inst/extdata/immune_map_azimuth.csv @@ -0,0 +1,30 @@ +from,to,is_immune +NK,nk,TRUE +CD8 TEM,cd8 tem,TRUE +CD4 CTL,cytotoxic,TRUE +dnT,t,TRUE +CD8 Naive,cd8 naive,TRUE +CD4 Naive,cd4 naive,TRUE +CD4 TCM,cd4 tcm,TRUE +gdT,tgd,TRUE +CD8 TCM,cd8 tcm,TRUE +MAIT,mait,TRUE +CD4 TEM,cd4 tem,TRUE +ILC,ilc,TRUE +CD14 Mono,cd14 mono,TRUE +cDC1,cdc,TRUE +pDC,pdc,TRUE +cDC2,cdc,TRUE +B naive,b naive,TRUE +B intermediate,b memory,TRUE +B memory,b memory,TRUE +Eryth,erythrocyte,TRUE +CD16 Mono,cd16 mono,TRUE +HSPC,progenitor,TRUE +Treg,treg,TRUE +NK_CD56bright,nk,TRUE +Plasmablast,plasma,TRUE +NK Proliferating,nk,TRUE +ASDC,cdc,TRUE +CD8 Proliferating,cd8 tem,TRUE +CD4 Proliferating,cd4 tem,TRUE \ No newline at end of file diff --git a/inst/extdata/immune_map_blueprint.csv b/inst/extdata/immune_map_blueprint.csv new file mode 100755 index 0000000..345c890 --- /dev/null +++ b/inst/extdata/immune_map_blueprint.csv @@ -0,0 +1,45 @@ +from,to,is_immune +Neutrophils,granulocyte,TRUE +Monocytes,monocytic,TRUE +MEP,progenitor,TRUE +CD4+ T-cells,t cd4,TRUE +Tregs,treg,TRUE +CD4+ Tcm,cd4 tcm,TRUE +CD4+ Tem,cd4 tem,TRUE +CD8+ Tcm,cd8 tcm,TRUE +CD8+ Tem,cd8 tem,TRUE +NK cells,nk,TRUE +naive B-cells,b naive,TRUE +Memory B-cells,b memory,TRUE +Class-switched memory B-cells,b memory,TRUE +HSC,progenitor,TRUE +MPP,progenitor,TRUE +CLP,progenitor,TRUE +GMP,progenitor,TRUE +Macrophages,macrophage,TRUE +CD8+ T-cells,t cd8,TRUE +CD8 T,t cd8,TRUE +Erythrocytes,erythrocyte,TRUE +Megakaryocytes,non immune,TRUE +CMP,progenitor,TRUE +Macrophages M1,macrophage,TRUE +Macrophages M2,macrophage,TRUE +Endothelial cells,non immune,TRUE +DC,cdc,TRUE +Eosinophils,granulocyte,TRUE +Plasma cells,plasma,TRUE +Chondrocytes,non immune,TRUE +Fibroblasts,non immune,TRUE +Smooth muscle,non immune,TRUE +Epithelial cells,non immune,TRUE +Melanocytes,non immune,TRUE +Skeletal muscle,non immune,TRUE +Keratinocytes,non immune,TRUE +mv Endothelial cells,non immune,TRUE +Myocytes,non immune,TRUE +Adipocytes,non immune,TRUE +Neurons,non immune,TRUE +Pericytes,non immune,TRUE +Preadipocytes,non immune,TRUE +Astrocytes,non immune,TRUE +Mesangial cells,non immune,TRUE \ No newline at end of file diff --git a/inst/extdata/immune_map_cellxgene.csv b/inst/extdata/immune_map_cellxgene.csv new file mode 100755 index 0000000..f835dbe --- /dev/null +++ b/inst/extdata/immune_map_cellxgene.csv @@ -0,0 +1,679 @@ +from,to,is_immune +"activated CD4-positive, alpha-beta T cell",cd4 tem,TRUE +"activated CD4-positive, alpha-beta T cell, human",cd4 tem,TRUE +"activated CD8-positive, alpha-beta T cell",cd8 tem,TRUE +"activated CD8-positive, alpha-beta T cell, human",cd8 tem,TRUE +activated type II NK T cell,nkt,TRUE +alpha-beta T cell,t,TRUE +alternatively activated macrophage,macrophage,TRUE +alveolar macrophage,macrophage,TRUE +B cell,b,TRUE +B-1 B cell,b,TRUE +B-1a B cell,b,TRUE +B-1b B cell,b,TRUE +B-2 B cell,b,TRUE +basophil,granulocyte,TRUE +basophil mast progenitor cell,progenitor,TRUE +blood cell,erythrocyte,TRUE +"CD14-low, CD16-positive monocyte",cd16 mono,TRUE +CD14-positive monocyte,cd14 mono,TRUE +"CD14-positive, CD16-negative classical monocyte",cd14 mono,TRUE +"CD14-positive, CD16-positive monocyte",monocytic,TRUE +CD141-positive myeloid dendritic cell,cdc,TRUE +"CD16-negative, CD56-bright natural killer cell, human",nk,TRUE +"CD16-positive, CD56-dim natural killer cell, human",nk,TRUE +CD1c-positive myeloid dendritic cell,cdc,TRUE +"CD34-positive, CD38-negative hematopoietic stem cell",progenitor,TRUE +"CD34-positive, CD56-positive, CD117-positive common innate lymphoid precursor, human",progenitor,TRUE +CD4-positive helper T cell,t cd4,TRUE +"CD4-positive, alpha-beta cytotoxic T cell",cytotoxic,TRUE +"CD4-positive, alpha-beta memory T cell",cd4 tcm,TRUE +"CD4-positive, alpha-beta T cell",t cd4,TRUE +"CD4-positive, alpha-beta thymocyte",cd4 naive,TRUE +"CD4-positive, CD25-positive, alpha-beta regulatory T cell",treg,TRUE +"CD8-alpha alpha positive, gamma-delta intraepithelial T cell",tgd,TRUE +"CD8-alpha-alpha-positive, alpha-beta intraepithelial T cell",t cd8,TRUE +"CD8-alpha-beta-positive, alpha-beta intraepithelial T cell",t cd8,TRUE +"CD8-positive, alpha-beta cytokine secreting effector T cell",t cd8,TRUE +"CD8-positive, alpha-beta cytotoxic T cell",t cd8,TRUE +"CD8-positive, alpha-beta memory T cell",cd8 tcm,TRUE +"CD8-positive, alpha-beta memory T cell, CD45RO-positive",cd8 tcm,TRUE +"CD8-positive, alpha-beta T cell",t cd8,TRUE +"CD8-positive, alpha-beta thymocyte",cd8 naive,TRUE +"central memory CD4-positive, alpha-beta T cell",cd4 tcm,TRUE +"central memory CD8-positive, alpha-beta T cell",cd8 tcm,TRUE +central nervous system macrophage,macrophage,TRUE +class switched memory B cell,b,TRUE +classical monocyte,monocytic,TRUE +colon macrophage,macrophage,TRUE +common dendritic progenitor,progenitor,TRUE +common lymphoid progenitor,progenitor,TRUE +common myeloid progenitor,progenitor,TRUE +conventional dendritic cell,cdc,TRUE +cord blood hematopoietic stem cell,progenitor,TRUE +cytotoxic T cell,cytotoxic,TRUE +"decidual natural killer cell, human",nk,TRUE +dendritic cell,dc,TRUE +"dendritic cell, human",dc,TRUE +DN1 thymic pro-T cell,t,TRUE +DN3 thymocyte,t,TRUE +DN4 thymocyte,t,TRUE +double negative T regulatory cell,treg,TRUE +double negative thymocyte,t,TRUE +"double-positive, alpha-beta thymocyte",t,TRUE +early lymphoid progenitor,progenitor,TRUE +early pro-B cell,b,TRUE +early promyelocyte,progenitor,TRUE +early T lineage precursor,progenitor,TRUE +"effector CD4-positive, alpha-beta T cell",cd4 tem,TRUE +"effector CD8-positive, alpha-beta T cell",cd8 tem,TRUE +"effector memory CD4-positive, alpha-beta T cell",cd4 tem,TRUE +"effector memory CD8-positive, alpha-beta T cell",cd8 tem,TRUE +"effector memory CD8-positive, alpha-beta T cell, terminally differentiated",cd8 tem,TRUE +elicited macrophage,macrophage,TRUE +enucleate erythrocyte,erythrocyte,TRUE +eosinophil,granulocyte,TRUE +erythroblast,erythrocyte,TRUE +erythrocyte,erythrocyte,TRUE +erythroid progenitor cell,progenitor,TRUE +"erythroid progenitor cell, mammalian",progenitor,TRUE +eurydendroid cell,progenitor,TRUE +follicular B cell,b,TRUE +fraction A pre-pro B cell,b,TRUE +gamma-delta T cell,tgd,TRUE +germinal center B cell,b,TRUE +granulocyte,granulocyte,TRUE +granulocyte monocyte progenitor cell,progenitor,TRUE +group 2 innate lymphoid cell,ilc,TRUE +"group 2 innate lymphoid cell, human",ilc,TRUE +group 3 innate lymphoid cell,ilc,TRUE +"group 3 innate lymphoid cell, human",ilc,TRUE +helper T cell,t cd4,TRUE +hematopoietic multipotent progenitor cell,progenitor,TRUE +hematopoietic precursor cell,progenitor,TRUE +hematopoietic stem cell,progenitor,TRUE +Hofbauer cell,macrophage,TRUE +IgA plasma cell,plasma,TRUE +IgA plasmablast,plasma,TRUE +IgG memory B cell,b memory,TRUE +IgG plasma cell,plasma,TRUE +IgG plasmablast,plasma,TRUE +IgG-negative class switched memory B cell,b,TRUE +IgM plasma cell,plasma,TRUE +"ILC1, human",ilc,TRUE +immature alpha-beta T cell,t,TRUE +immature B cell,b,TRUE +immature innate lymphoid cell,ilc,TRUE +immature natural killer cell,nk,TRUE +immature neutrophil,granulocyte,TRUE +immature NK T cell,nkt,TRUE +inflammatory macrophage,macrophage,TRUE +innate lymphoid cell,ilc,TRUE +intermediate monocyte,monocytic,TRUE +kidney interstitial alternatively activated macrophage,macrophage,TRUE +Kupffer cell,macrophage,TRUE +large pre-B-II cell,b,TRUE +late pro-B cell,b,TRUE +late promyelocyte,progenitor,TRUE +liver dendritic cell,dc,TRUE +lung interstitial macrophage,macrophage,TRUE +lung macrophage,macrophage,TRUE +"lung resident memory CD4-positive, alpha-beta T cell",cd4 tcm,TRUE +"lung resident memory CD8-positive, alpha-beta T cell",t cd8,TRUE +lymphocyte of B lineage,b,TRUE +lymphoid lineage restricted progenitor cell,progenitor,TRUE +macrophage,macrophage,TRUE +macrophage dendritic cell progenitor,progenitor,TRUE +mast cell,mast,TRUE +mature alpha-beta T cell,t,TRUE +mature B cell,b,TRUE +mature conventional dendritic cell,cdc,TRUE +mature gamma-delta T cell,tgd,TRUE +mature NK T cell,nkt,TRUE +mature T cell,t,TRUE +memory B cell,b memory,TRUE +memory regulatory T cell,treg,TRUE +memory T cell,t,TRUE +MHC-II-positive classical monocyte,monocytic,TRUE +monocyte,monocytic,TRUE +monocyte-derived dendritic cell,monocytic,TRUE +mucosal invariant T cell,mait,TRUE +myeloid dendritic cell,cdc,TRUE +"myeloid dendritic cell, human",cdc,TRUE +myeloid lineage restricted progenitor cell,progenitor,TRUE +naive B cell,b naive,TRUE +naive regulatory T cell,treg,TRUE +naive T cell,t,TRUE +"naive thymus-derived CD4-positive, alpha-beta T cell",cd4 naive,TRUE +"naive thymus-derived CD8-positive, alpha-beta T cell",cd8 naive,TRUE +natural killer cell,nk,TRUE +natural T-regulatory cell,treg,TRUE +neutrophil,granulocyte,TRUE +neutrophil progenitor cell,progenitor,TRUE +"NKp44-negative group 3 innate lymphoid cell, human",ilc,TRUE +"NKp44-positive group 3 innate lymphoid cell, human",ilc,TRUE +non-classical monocyte,monocytic,TRUE +plasma cell,plasma,TRUE +plasmablast,plasma,TRUE +plasmacytoid dendritic cell,pdc,TRUE +"plasmacytoid dendritic cell, human",pdc,TRUE +pre-B-I cell,b,TRUE +pre-conventional dendritic cell,cdc,TRUE +pre-natural killer cell,nk,TRUE +precursor B cell,b,TRUE +primitive red blood cell,erythrocyte,TRUE +pro-B cell,b,TRUE +pro-T cell,t,TRUE +proerythroblast,erythrocyte,TRUE +promonocyte,monocytic,TRUE +regulatory T cell,treg,TRUE +small pre-B-II cell,b,TRUE +T cell,t,TRUE +T follicular helper cell,cd4 fh em,TRUE +T follicular regulatory cell,treg,TRUE +T-helper 1 cell,cd4 th1 em,TRUE +T-helper 17 cell,cd4 th17 em,TRUE +T-helper 2 cell,cd4 th2 em,TRUE +T-helper 22 cell,t cd4,TRUE +Tc1 cell,t cd8,TRUE +thymocyte,t,TRUE +tonsil germinal center B cell,b,TRUE +transitional stage B cell,b,TRUE +type I NK T cell,nkt,TRUE +unswitched memory B cell,b,TRUE +stromal cell,stromal,FALSE +oligodendrocyte precursor cell,glial,FALSE +mucous neck cell,secretory,FALSE +nasal mucosa goblet cell,secretory,FALSE +ionocyte,secretory,FALSE +parietal epithelial cell,epithelial,FALSE +transit amplifying cell,progenitor,FALSE +platelet,immune,FALSE +capillary endothelial cell,endothelial,FALSE +fibroblast of lung,stromal,FALSE +smooth muscle cell of the pulmonary artery,muscle,FALSE +chondrocyte,cartilage,FALSE +abnormal cell,other,FALSE +paneth cell,secretory,FALSE +PP cell,endocrine,FALSE +endothelial cell of pericentral hepatic sinusoid,endothelial,FALSE +GABAergic neuron,neuron,FALSE +squamous epithelial cell,epithelial,FALSE +embryonic fibroblast,stromal,FALSE +mesenchymal cell,stromal,FALSE +kidney cell,renal,FALSE +kidney loop of Henle epithelial cell,epithelial,FALSE +retinal bipolar neuron,neuron,FALSE +epithelial cell of nephron,epithelial,FALSE +type D enteroendocrine cell,endocrine,FALSE +motor neuron,neuron,FALSE +migratory enteric neural crest cell,neuron,FALSE +skeletal muscle satellite stem cell,muscle,FALSE +subcutaneous adipocyte,fat,FALSE +epicardial adipocyte,fat,FALSE +diffuse bipolar 1 cell,neuron,FALSE +invaginating midget bipolar cell,neuron,FALSE +cardiac muscle myoblast,muscle,FALSE +preosteoblast,progenitor,FALSE +serous secreting cell,epithelial,FALSE +cortical thymic epithelial cell,epithelial,FALSE +OFF-bipolar cell,neuron,FALSE +colon epithelial cell,epithelial,FALSE +transit amplifying cell of colon,progenitor,FALSE +acinar cell of salivary gland,secretory,FALSE +prostate gland microvascular endothelial cell,endothelial,FALSE +indirect pathway medium spiny neuron,neuron,FALSE +direct pathway medium spiny neuron,neuron,FALSE +epithelial cell of proximal tubule segment 3,epithelial,FALSE +skeletal muscle satellite cell,muscle,FALSE +L5/6 near-projecting glutamatergic neuron,neuron,FALSE +respiratory epithelial cell,epithelial,FALSE +type N enteroendocrine cell,endocrine,FALSE +skeletal muscle fiber,muscle,FALSE +vascular lymphangioblast,progenitor,FALSE +progenitor cell of mammary luminal epithelium,epithelial,FALSE +hair follicular keratinocyte,epidermal,FALSE +cerebellar granule cell precursor,progenitor,FALSE +unipolar brush cell,secretory,FALSE +anterior lens cell,lens,FALSE +stromal cell of endometrium,stromal,FALSE +CNS interneuron,neuron,FALSE +transit amplifying cell of small intestine,progenitor,FALSE +centroblast,immune,FALSE +tongue muscle cell,muscle,FALSE +pigmented ciliary epithelial cell,epithelial,FALSE +pulmonary interstitial fibroblast,stromal,FALSE +hepatoblast,progenitor,FALSE +sebum secreting cell,fat,FALSE +epithelial cell of uterus,epithelial,FALSE +microfold cell of epithelium of small intestine,epithelial,FALSE +dopaminergic neuron,neuron,FALSE +connective tissue cell,stromal,FALSE +myometrial cell,muscle,FALSE +kidney collecting duct cell,renal,FALSE +Schwann cell precursor,glial,FALSE +type A enteroendocrine cell,endocrine,FALSE +dermis microvascular lymphatic vessel endothelial cell,endothelial,FALSE +intestinal crypt stem cell of large intestine,progenitor,FALSE +type B pancreatic cell,endocrine,FALSE +kidney loop of Henle thick ascending limb epithelial cell,epithelial,FALSE +mesangial cell,renal,FALSE +pancreatic stellate cell,stromal,FALSE +stem cell,progenitor,FALSE +cardiac muscle cell,muscle,FALSE +astrocyte,glial,FALSE +multi-ciliated epithelial cell,epithelial,FALSE +bronchial goblet cell,secretory,FALSE +mucus secreting cell,secretory,FALSE +luminal hormone-sensing cell of mammary gland,endocrine,FALSE +placental villous trophoblast,progenitor,FALSE +perivascular cell,pericyte,FALSE +epithelial cell of proximal tubule,epithelial,FALSE +M cell of gut,epithelial,FALSE +glial cell,glial,FALSE +adventitial cell,stromal,FALSE +alveolar type 2 fibroblast cell,progenitor,FALSE +hepatocyte,liver,FALSE +brush cell,secretory,FALSE +endothelial cell of periportal hepatic sinusoid,endothelial,FALSE +differentiation-committed oligodendrocyte precursor,glial,FALSE +kidney interstitial cell,stromal,FALSE +kidney collecting duct intercalated cell,renal,FALSE +hepatic pit cell,immune,FALSE +retinal ganglion cell,neuron,FALSE +neural progenitor cell,neuron,FALSE +airway submucosal gland duct basal cell,epithelial,FALSE +blood vessel smooth muscle cell,muscle,FALSE +respiratory suprabasal cell,epithelial,FALSE +hematopoietic cell,immune,FALSE +glycinergic amacrine cell,neuron,FALSE +pancreatic epsilon cell,endocrine,FALSE +tracheobronchial serous cell,epithelial,FALSE +intrahepatic cholangiocyte,epithelial,FALSE +muscle precursor cell,muscle,FALSE +tracheobronchial goblet cell,secretory,FALSE +intestinal crypt stem cell,progenitor,FALSE +intestinal tuft cell,epithelial,FALSE +luminal cell of prostate epithelium,epithelial,FALSE +L6 corticothalamic-projecting glutamatergic cortical neuron,neuron,FALSE +decidual cell,reproductive,FALSE +neuron associated cell,neuron,FALSE +lactocyte,epithelial,FALSE +epithelial cell of prostate,epithelial,FALSE +epithelial cell of exocrine pancreas,epithelial,FALSE +chandelier cell,neuron,FALSE +ciliary muscle cell,muscle,FALSE +regular atrial cardiac myocyte,muscle,FALSE +paneth cell of epithelium of small intestine,epithelial,FALSE +reticulocyte,blood,FALSE +epithelial cell of sweat gland,epithelial,FALSE +kidney connecting tubule principal cell,renal,FALSE +chorionic trophoblast cell,progenitor,FALSE +myoblast,muscle,FALSE +glomerular capillary endothelial cell,endothelial,FALSE +large intestine goblet cell,secretory,FALSE +erythroid lineage cell,blood,FALSE +fibroblast of cardiac tissue,stromal,FALSE +pancreatic A cell,endocrine,FALSE +melanocyte,epidermal,FALSE +cardiac endothelial cell,endothelial,FALSE +enterocyte,epithelial,FALSE +lymphocyte,immune,FALSE +pericyte,pericyte,FALSE +oligodendrocyte,glial,FALSE +leukocyte,immune,FALSE +adipocyte,fat,FALSE +corticothalamic-projecting glutamatergic cortical neuron,neuron,FALSE +vascular leptomeningeal cell,pericyte,FALSE +L6b glutamatergic cortical neuron,neuron,FALSE +cerebral cortex endothelial cell,endothelial,FALSE +respiratory basal cell,epithelial,FALSE +luminal epithelial cell of mammary gland,epithelial,FALSE +extravillous trophoblast,progenitor,FALSE +endothelial cell of artery,endothelial,FALSE +enterocyte of colon,epithelial,FALSE +pulmonary artery endothelial cell,endothelial,FALSE +cholangiocyte,epithelial,FALSE +epithelial cell of lung,epithelial,FALSE +uterine smooth muscle cell,muscle,FALSE +alveolar type 1 fibroblast cell,progenitor,FALSE +preadipocyte,fat,FALSE +acinar cell,secretory,FALSE +enteric neuron,neuron,FALSE +peptic cell,secretory,FALSE +Schwann cell,glial,FALSE +inhibitory interneuron,neuron,FALSE +Mueller cell,glial,FALSE +myoepithelial cell,myoepithelial,FALSE +interstitial cell of Cajal,stromal,FALSE +brush cell of trachebronchial tree,secretory,FALSE +epithelial cell of thymus,epithelial,FALSE +deuterosomal cell,epithelial,FALSE +peripheral nervous system neuron,neuron,FALSE +parasol ganglion cell of retina,neuron,FALSE +professional antigen presenting cell,immune,FALSE +bipolar neuron,neuron,FALSE +precursor cell,progenitor,FALSE +neural crest cell,neuron,FALSE +neuronal brush cell,secretory,FALSE +epithelial cell of urethra,epithelial,FALSE +medium spiny neuron,neuron,FALSE +meningeal macrophage,macrophage,TRUE +follicular dendritic cell,immune,FALSE +trophoblast giant cell,progenitor,FALSE +sympathetic neuron,neuron,FALSE +noradrenergic cell,neuron,FALSE +vasa recta ascending limb cell,renal,FALSE +ovarian surface epithelial cell,epithelial,FALSE +brainstem motor neuron,neuron,FALSE +"BEST4+ intestinal epithelial cell, human",epithelial,FALSE +centrocyte,immune,FALSE +duodenum glandular cell,epithelial,FALSE +ileal goblet cell,secretory,FALSE +non-pigmented ciliary epithelial cell,epithelial,FALSE +epidermal cell,epidermal,FALSE +kidney pelvis urothelial cell,epithelial,FALSE +epithelial cell,epithelial,FALSE +megakaryocyte,blood,FALSE +fibroblast,progenitor,FALSE +enteric smooth muscle cell,muscle,FALSE +gut endothelial cell,endothelial,FALSE +intestine goblet cell,secretory,FALSE +astrocyte of the cerebral cortex,glial,FALSE +ciliated columnar cell of tracheobronchial tree,epithelial,FALSE +renal principal cell,renal,FALSE +malignant cell,other,FALSE +lung pericyte,pericyte,FALSE +neoplastic cell,other,FALSE +glandular epithelial cell,epithelial,FALSE +keratinocyte,epidermal,FALSE +epithelial cell of lower respiratory tract,epithelial,FALSE +taste receptor cell,sensory,FALSE +syncytiotrophoblast cell,progenitor,FALSE +fetal cardiomyocyte,muscle,FALSE +enteroendocrine cell of colon,endocrine,FALSE +smooth muscle cell,muscle,FALSE +kidney interstitial fibroblast,stromal,FALSE +germ cell,reproductive,FALSE +macroglial cell,glial,FALSE +respiratory hillock cell,epithelial,FALSE +primary sensory neuron (sensu Teleostei),neuron,FALSE +photoreceptor cell,neuron,FALSE +epithelial cell of alveolus of lung,epithelial,FALSE +pancreatic PP cell,endocrine,FALSE +fast muscle cell,muscle,FALSE +neuroendocrine cell,endocrine,FALSE +megakaryocyte progenitor cell,blood,FALSE +regular ventricular cardiac myocyte,muscle,FALSE +Sertoli cell,reproductive,FALSE +rod bipolar cell,neuron,FALSE +diffuse bipolar 4 cell,neuron,FALSE +flat midget bipolar cell,neuron,FALSE +midget ganglion cell of retina,neuron,FALSE +pulmonary ionocyte,secretory,FALSE +Bergmann glial cell,glial,FALSE +bladder urothelial cell,epithelial,FALSE +endosteal cell,bone,FALSE +melanocyte of skin,epidermal,FALSE +cone retinal bipolar cell,neuron,FALSE +neuron associated cell (sensu Vertebrata),neuron,FALSE +granule cell,neuron,FALSE +non-myelinating Schwann cell,glial,FALSE +renal intercalated cell,renal,FALSE +salivary gland cell,epithelial,FALSE +sensory neuron,neuron,FALSE +collagen secreting cell,stromal,FALSE +immature astrocyte,glial,FALSE +cerebral cortex GABAergic interneuron,neuron,FALSE +pigmented epithelial cell,epithelial,FALSE +columnar/cuboidal epithelial cell,epithelial,FALSE +immature Schwann cell,glial,FALSE +kidney distal convoluted tubule epithelial cell,epithelial,FALSE +basal cell of epidermis,epithelial,FALSE +mural cell,pericyte,FALSE +myofibroblast cell,stromal,FALSE +foveolar cell of stomach,epithelial,FALSE +myeloid cell,immune,FALSE +microglial cell,glial,FALSE +pvalb GABAergic cortical interneuron,neuron,FALSE +near-projecting glutamatergic cortical neuron,neuron,FALSE +endothelial cell of placenta,endothelial,FALSE +absorptive cell,epithelial,FALSE +type II pneumocyte,pneumocyte,FALSE +type L enteroendocrine cell,endocrine,FALSE +cerebellar granule cell,neuron,FALSE +kidney loop of Henle thin ascending limb epithelial cell,epithelial,FALSE +retinal pigment epithelial cell,epithelial,FALSE +midzonal region hepatocyte,liver,FALSE +centrilobular region hepatocyte,liver,FALSE +stromal cell of ovary,stromal,FALSE +tracheobronchial smooth muscle cell,muscle,FALSE +renal alpha-intercalated cell,renal,FALSE +basal epithelial cell of tracheobronchial tree,epithelial,FALSE +colon goblet cell,secretory,FALSE +P/D1 enteroendocrine cell,endocrine,FALSE +granulosa cell,reproductive,FALSE +fibro/adipogenic progenitor cell,progenitor,FALSE +forebrain neuroblast,progenitor,FALSE +radial glial cell,glial,FALSE +interneuron,neuron,FALSE +bronchial smooth muscle cell,muscle,FALSE +lung neuroendocrine cell,endocrine,FALSE +lung goblet cell,secretory,FALSE +medullary thymic epithelial cell,epithelial,FALSE +small intestine goblet cell,secretory,FALSE +H1 horizontal cell,neuron,FALSE +giant bipolar cell,neuron,FALSE +OFFx cell,neuron,FALSE +hepatic stellate cell,liver,FALSE +neuronal receptor cell,sensory,FALSE +epithelial cell of proximal tubule segment 1,epithelial,FALSE +lens fiber cell,lens,FALSE +basal cell of prostate epithelium,epithelial,FALSE +Cajal-Retzius cell,neuron,FALSE +corneal endothelial cell,endothelial,FALSE +glioblast,glial,FALSE +smooth muscle cell of prostate,muscle,FALSE +secondary lens fiber,lens,FALSE +sst chodl GABAergic cortical interneuron,neuron,FALSE +pancreatic endocrine cell,endocrine,FALSE +paneth cell of colon,secretory,FALSE +myelinating Schwann cell,glial,FALSE +primary cultured cell,other,FALSE +prostate stromal cell,stromal,FALSE +epidermal Langerhans cell,immune,FALSE +primordial germ cell,reproductive,FALSE +endothelial cell of vascular tree,endothelial,FALSE +epithelial cell of esophagus,epithelial,FALSE +mesothelial cell,mesothelial,FALSE +vein endothelial cell,endothelial,FALSE +sst GABAergic cortical interneuron,neuron,FALSE +caudal ganglionic eminence derived GABAergic cortical interneuron,neuron,FALSE +sncg GABAergic cortical interneuron,neuron,FALSE +luminal adaptive secretory precursor cell of mammary gland,progenitor,FALSE +myoepithelial cell of mammary gland,myoepithelial,FALSE +fibroblast of mammary gland,stromal,FALSE +kidney connecting tubule epithelial cell,epithelial,FALSE +intestinal enteroendocrine cell,endocrine,FALSE +type I pneumocyte,pneumocyte,FALSE +endothelial cell of hepatic sinusoid,endothelial,FALSE +glutamatergic neuron,neuron,FALSE +ciliated cell,epithelial,FALSE +secretory cell,secretory,FALSE +stratified epithelial cell,epithelial,FALSE +skin fibroblast,stromal,FALSE +type G enteroendocrine cell,endocrine,FALSE +myelocyte,immune,FALSE +chromaffin cell,endocrine,FALSE +reticular cell,immune,FALSE +renal interstitial pericyte,renal,FALSE +basal cell of epithelium of trachea,epithelial,FALSE +amacrine cell,neuron,FALSE +myeloid leukocyte,immune,FALSE +slow muscle cell,muscle,FALSE +enterocyte of epithelium of small intestine,epithelial,FALSE +ciliated epithelial cell,epithelial,FALSE +Leydig cell,reproductive,FALSE +GABAergic amacrine cell,neuron,FALSE +diffuse bipolar 3b cell,neuron,FALSE +osteoblast,progenitor,FALSE +corneal epithelial cell,epithelial,FALSE +mature microglial cell,glial,FALSE +mature astrocyte,glial,FALSE +retinal astrocyte,glial,FALSE +brush cell of trachea,secretory,FALSE +mesothelial cell of epicardium,mesothelial,FALSE +thyroid follicular cell,endocrine,FALSE +visceromotor neuron,neuron,FALSE +choroid plexus epithelial cell,epithelial,FALSE +skeletal muscle fibroblast,muscle,FALSE +bronchial epithelial cell,epithelial,FALSE +cortical cell of adrenal gland,endocrine,FALSE +inflammatory cell,immune,FALSE +fibroblast of connective tissue of glandular part of prostate,stromal,FALSE +vasa recta descending limb cell,renal,FALSE +lung microvascular endothelial cell,endothelial,FALSE +conjunctival epithelial cell,epithelial,FALSE +smooth muscle cell of sphincter of pupil,muscle,FALSE +eye photoreceptor cell,neuron,FALSE +epithelial cell of small intestine,epithelial,FALSE +pyramidal neuron,neuron,FALSE +sebaceous gland cell,epithelial,FALSE +granular cell of epidermis,epithelial,FALSE +bone marrow cell,bone,FALSE +mesothelial cell of pleura,mesothelial,FALSE +neuron,neuron,FALSE +endothelial cell,endothelial,FALSE +prickle cell,epidermal,FALSE +renal beta-intercalated cell,renal,FALSE +intestinal epithelial cell,epithelial,FALSE +enteroendocrine cell,endocrine,FALSE +L2/3-6 intratelencephalic projecting glutamatergic neuron,neuron,FALSE +vip GABAergic cortical interneuron,neuron,FALSE +club cell,epithelial,FALSE +mammary gland epithelial cell,epithelial,FALSE +endothelial cell of uterus,endothelial,FALSE +endothelial cell of lymphatic vessel,endothelial,FALSE +vascular associated smooth muscle cell,muscle,FALSE +lung perichondrial fibroblast,stromal,FALSE +type EC enteroendocrine cell,endocrine,FALSE +pancreatic acinar cell,secretory,FALSE +supporting cell,epithelial,FALSE +contractile cell,muscle,FALSE +theca cell,reproductive,FALSE +stem cell of epidermis,epithelial,FALSE +retinal rod cell,neuron,FALSE +promyelocyte,immune,FALSE +brain vascular cell,pericyte,FALSE +progenitor cell,progenitor,FALSE +kidney capillary endothelial cell,endothelial,FALSE +mesodermal cell,stromal,FALSE +GIP cell,endocrine,FALSE +mesenchymal lymphangioblast,progenitor,FALSE +mesothelial fibroblast,stromal,FALSE +tendon cell,stromal,FALSE +S cone cell,neuron,FALSE +diffuse bipolar 2 cell,neuron,FALSE +diffuse bipolar 6 cell,neuron,FALSE +parietal cell,epithelial,FALSE +smooth muscle myoblast,muscle,FALSE +endothelial cell of sinusoid,endothelial,FALSE +mononuclear phagocyte,immune,FALSE +retina horizontal cell,neuron,FALSE +embryonic stem cell,progenitor,FALSE +suprabasal keratinocyte,epidermal,FALSE +papillary tips cell,renal,FALSE +retinal blood vessel endothelial cell,endothelial,FALSE +kidney loop of Henle ascending limb epithelial cell,epithelial,FALSE +L4 intratelencephalic projecting glutamatergic neuron,neuron,FALSE +sperm,reproductive,FALSE +fibroblast of connective tissue of nonglandular part of prostate,stromal,FALSE +lens epithelial cell,epithelial,FALSE +glomerular endothelial cell,endothelial,FALSE +kidney resident macrophage,macrophage,TRUE +epithelial cell of stratum germinativum of esophagus,epithelial,FALSE +basal epithelial cell of prostatic duct,epithelial,FALSE +serous cell of epithelium of bronchus,epithelial,FALSE +urothelial cell,epithelial,FALSE +GABAergic interneuron,neuron,FALSE +intestinal crypt stem cell of small intestine,progenitor,FALSE +enterocyte of epithelium proper of ileum,epithelial,FALSE +smooth muscle fiber of ileum,muscle,FALSE +L6 intratelencephalic projecting glutamatergic neuron of the primary motor cortex,neuron,FALSE +ventricular cardiac muscle cell,muscle,FALSE +endocrine cell,endocrine,FALSE +mesenchymal stem cell,progenitor,FALSE +unknown,other,FALSE +neural cell,neuron,FALSE +cardiac neuron,neuron,FALSE +lamp5 GABAergic cortical interneuron,neuron,FALSE +chandelier pvalb GABAergic cortical interneuron,neuron,FALSE +L5 extratelencephalic projecting glutamatergic cortical neuron,neuron,FALSE +blood vessel endothelial cell,endothelial,FALSE +basal cell,epithelial,FALSE +intestinal crypt stem cell of colon,progenitor,FALSE +goblet cell,secretory,FALSE +bronchus fibroblast of lung,progenitor,FALSE +lung secretory cell,secretory,FALSE +metallothionein-positive alveolar macrophage,macrophage,TRUE +pancreatic ductal cell,endocrine,FALSE +pancreatic D cell,endocrine,FALSE +kidney collecting duct principal cell,renal,FALSE +kidney loop of Henle thin descending limb epithelial cell,epithelial,FALSE +periportal region hepatocyte,liver,FALSE +Merkel cell,sensory,FALSE +megakaryocyte-erythroid progenitor cell,blood,FALSE +endothelial tip cell,endothelial,FALSE +glandular cell of esophagus,epithelial,FALSE +kidney epithelial cell,epithelial,FALSE +podocyte,renal,FALSE +interstitial cell of ovary,stromal,FALSE +tracheal goblet cell,secretory,FALSE +lung ciliated cell,epithelial,FALSE +cortical interneuron,neuron,FALSE +ependymal cell,glial,FALSE +serous secreting cell of bronchus submucosal gland,epithelial,FALSE +enucleated reticulocyte,blood,FALSE +neuroblast (sensu Vertebrata),progenitor,FALSE +type I enteroendocrine cell,endocrine,FALSE +fibroblast of breast,stromal,FALSE +retinal cone cell,neuron,FALSE +enterocyte of epithelium of large intestine,epithelial,FALSE +H2 horizontal cell,neuron,FALSE +diffuse bipolar 3a cell,neuron,FALSE +starburst amacrine cell,neuron,FALSE +ON-blue cone bipolar cell,neuron,FALSE +duct epithelial cell,epithelial,FALSE +adipocyte of epicardial fat of left ventricle,fat,FALSE +osteoclast,bone,FALSE +adipocyte of breast,fat,FALSE +cell of skeletal muscle,muscle,FALSE +ganglion interneuron,neuron,FALSE +muscle cell,muscle,FALSE +Purkinje cell,neuron,FALSE +stellate neuron,neuron,FALSE +ON-bipolar cell,neuron,FALSE +forebrain radial glial cell,glial,FALSE +L2/3 intratelencephalic projecting glutamatergic neuron,neuron,FALSE +cerebral cortex neuron,neuron,FALSE +inhibitory motor neuron,neuron,FALSE +tuft cell of colon,epithelial,FALSE +respiratory goblet cell,secretory,FALSE +progenitor cell of endocrine pancreas,progenitor,FALSE +epithelial fate stem cell,epithelial,FALSE +enteroendocrine cell of small intestine,endocrine,FALSE +keratocyte,epithelial,FALSE +endocardial cell,endothelial,FALSE +cardiac mesenchymal cell,stromal,FALSE +L5/6 near-projecting glutamatergic neuron of the primary motor cortex,neuron,FALSE +Langerhans cell,immune,FALSE +surface ectodermal cell,epithelial,FALSE +serous cell of epithelium of trachea,epithelial,FALSE +epithelial cell of lacrimal sac,epithelial,FALSE +intraepithelial lymphocyte,progenitor,FALSE +pneumocyte,pneumocyte,FALSE +non-terminally differentiated cell,progenitor,FALSE +mononuclear cell,immune,FALSE +peripheral blood mononuclear cell,immune,FALSE +exhausted T cell,t,TRUE +endothelial cell of venule,endothelial,FALSE \ No newline at end of file diff --git a/inst/extdata/immune_map_monaco.csv b/inst/extdata/immune_map_monaco.csv new file mode 100755 index 0000000..970f26e --- /dev/null +++ b/inst/extdata/immune_map_monaco.csv @@ -0,0 +1,38 @@ +from,to,is_immune +Naive CD8 T cells,cd8 naive,TRUE +Central memory CD8 T cells,cd8 tcm,TRUE +Effector memory CD8 T cells,cd8 tem,TRUE +Terminal effector CD8 T cells,cd8 tem,TRUE +MAIT cells,mait,TRUE +Vd2 gd T cells,tgd,TRUE +Non-Vd2 gd T cells,tgd,TRUE +Follicular helper T cells,cd4 fh em,TRUE +T regulatory cells,treg,TRUE +Th1 cells,cd4 th1 em,TRUE +Th1/Th17 cells,cd4 th1/th17 em,TRUE +Th17 cells,cd4 th17 em,TRUE +Th2 cells,cd4 th2 em,TRUE +Naive CD4 T cells,cd4 naive,TRUE +Progenitor cells,progenitor,TRUE +Naive B cells,b naive,TRUE +Naive B,b naive,TRUE +Non-switched memory B cells,b memory,TRUE +Nonswitched memory B,b memory,TRUE +Exhausted B cells,plasma,TRUE +Switched memory B cells,b memory,TRUE +Switched memory B,b memory,TRUE +Plasmablasts,plasma,TRUE +Classical monocytes,cd14 mono,TRUE +Intermediate monocytes,cd14 mono,TRUE +Non classical monocytes,cd16 mono,TRUE +Natural killer cells,nk,TRUE +Natural killer,nk,TRUE +Plasmacytoid dendritic cells,pdc,TRUE +Myeloid dendritic cells,cdc,TRUE +Myeloid dendritic,cdc,TRUE +Low-density neutrophils,granulocyte,TRUE +Lowdensity neutrophils,granulocyte,TRUE +Low-density basophils,granulocyte,TRUE +Lowdensity basophils,granulocyte,TRUE +Terminal effector CD4 T cells,cd4 tem,TRUE +progenitor,progenitor,TRUE \ No newline at end of file diff --git a/inst/extdata/immune_tree.csv b/inst/extdata/immune_tree.csv new file mode 100755 index 0000000..69d0adf --- /dev/null +++ b/inst/extdata/immune_tree.csv @@ -0,0 +1,38 @@ +,b,b memory,b naive,plasma,ilc,nkt,nk,t,t cd4,cd4 naive,cd4 tcm,cd4 tem,cd4 fh em,cd4 th1/th17 em,cd4 th1 em,cd4 th2 em,cd4 th17 em,t cd8,cd8 naive,cd8 tcm,cd8 tem,tgd,treg,mait,cytotoxic,erythrocyte,granulocyte,monocytic,cd14 mono,cd16 mono,dc,cdc,pdc,macrophage,mast,progenitor,non immune +b,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +monocytic,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,2,0,0,0 +cd14 mono,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +cd16 mono,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +dc,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0 +cdc,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +pdc,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +macrophage,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +mast,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +progenitor,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +non immune,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 \ No newline at end of file diff --git a/inst/scripts/build_graph.R b/inst/scripts/build_graph.R new file mode 100644 index 0000000..9229469 --- /dev/null +++ b/inst/scripts/build_graph.R @@ -0,0 +1,12 @@ +library(igraph) + +# load knowledge graph +adj_immune = read.csv("inst/extdata/immune_tree.csv", row.names = 1, check.names = FALSE) |> + as.matrix() +immune_graph = graph_from_adjacency_matrix(adj_immune, mode = "directed", weighted = TRUE) + +# Hierarchy - true (known) hierarchical relationships +# Consensus-only - temporary relationship used for ambiguous or often confused classes (e.g. macrophages and monocytes are often considered a single class but macrophages are not monocytes) +E(immune_graph)$Type = ifelse(E(immune_graph)$weight == 1, "Hierarchy", "Consensus-only") +E(immune_graph)$weight = 1 +usethis::use_data(immune_graph) diff --git a/inst/scripts/build_unification_maps.R b/inst/scripts/build_unification_maps.R new file mode 100644 index 0000000..3777a9e --- /dev/null +++ b/inst/scripts/build_unification_maps.R @@ -0,0 +1,41 @@ +library(tidyverse) + +# load mappings between predictions and our dictionary +map_files = list.files("inst/extdata", pattern = "immune_map.+.csv", full.names = TRUE) +names(map_files) = gsub("immune_map_(.+).csv", "\\1", basename(map_files)) +celltype_unification_maps = map_files |> + lapply(read.csv) + +nonimmune_cellxgene = celltype_unification_maps$cellxgene |> + filter(!is_immune) |> + pull("to") |> + unique() + +# harmonise to a common nomenclature +celltype_unification_maps$azimuth = celltype_unification_maps$azimuth |> + select(from, to) |> + dplyr::rename( + azimuth_predicted_celltype_l2 = from, + azimuth = to + ) +celltype_unification_maps$blueprint = celltype_unification_maps$blueprint |> + select(from, to) |> + dplyr::rename( + blueprint_first_labels_fine = from, + blueprint = to + ) +celltype_unification_maps$monaco = celltype_unification_maps$monaco |> + select(from, to) |> + dplyr::rename( + monaco_first_labels_fine = from, + monaco = to + ) +celltype_unification_maps$cellxgene = celltype_unification_maps$cellxgene |> + select(from, to) |> + dplyr::rename( + cell_type = from, + cell_type_unified = to + ) + +usethis::use_data(celltype_unification_maps) +usethis::use_data(nonimmune_cellxgene) diff --git a/inst/scripts/example_run.R b/inst/scripts/example_run.R new file mode 100644 index 0000000..500442c --- /dev/null +++ b/inst/scripts/example_run.R @@ -0,0 +1,36 @@ +data(celltype_unification_maps) +data(nonimmune_cellxgene) + +# unify cell types +cell_metadata = cell_metadata |> + left_join(celltype_unification_maps$azimuth, copy = TRUE) |> + left_join(celltype_unification_maps$blueprint, copy = TRUE) |> + left_join(celltype_unification_maps$monaco, copy = TRUE) |> + left_join(celltype_unification_maps$cellxgene, copy = TRUE) |> + mutate(ensemble_joinid = paste(azimuth, blueprint, monaco, cell_type_unified, sep = "_")) + +# produce the ensemble map +df_map = cell_metadata |> + count(ensemble_joinid, azimuth, blueprint, monaco, cell_type_unified, name = "NCells") |> + as_tibble() |> + mutate( + cellxgene = if_else(cell_type_unified %in% nonimmune_cellxgene, "non immune", cell_type_unified), + data_driven_ensemble = ensemble_annotation(cbind(azimuth, blueprint, monaco), override_celltype = c("non immune", "nkt", "mast")), + cell_type_unified_ensemble = ensemble_annotation(cbind(azimuth, blueprint, monaco, cellxgene), method_weights = c(1, 1, 1, 2), override_celltype = c("non immune", "nkt", "mast")), + cell_type_unified_ensemble = case_when( + cell_type_unified_ensemble == "non immune" & cellxgene == "non immune" ~ cell_type_unified, + cell_type_unified_ensemble == "non immune" & cellxgene != "non immune" ~ "other", + .default = cell_type_unified_ensemble + ), + is_immune = !cell_type_unified_ensemble %in% nonimmune_cellxgene + ) |> + select( + ensemble_joinid, + data_driven_ensemble, + cell_type_unified_ensemble, + is_immune + ) + +# use map to perform cell type ensemble +cell_metadata = cell_metadata |> + left_join(df_map, by = join_by(ensemble_joinid), copy = TRUE) \ No newline at end of file