
Prepare gene sets
prepare-gene-sets.RmdUsing gene sets from ScType
hitype is designed to be compatible with ScType. So the
gene sets provided by ScType can be
used directly.
library(hitype)
gs <- gs_prepare(
"https://raw.githubusercontent.com/IanevskiAleksandr/sc-type/master/ScTypeDB_short.xlsx"
)
gs$gene_sets[[1]]$`Acinar cells`
#> $markers
#> [1] "CTRB1" "KLK1" "RBPJL" "PTF1A" "CELA3A" "PRSS1"
#> [7] "SPINK1" "ZG16" "CEL" "CELA2A" "CPB1" "CELA1"
#> [13] "RNASE1" "AMY2B" "CPA2" "CPA1" "CELA3B" "PNLIP"
#> [19] "CTRB2" "PLA2G1B" "PRSS2" "CLPS" "REG1A" "SYCN"
#> [25] "PNLIPRP1" "CTRC" "REG3A" "PRSS3" "REG1B" "CFB"
#> [31] "GDF15" "MUC1" "C15orf48" "AKR1C3" "OLFM4" "GSTA1"
#> [37] "LGALS2" "PDZK1IP1" "RARRES2" "CXCL17" "GSTA2" "ANPEP"
#> [43] "LYZ" "ANGPTL4" "ALDOB"
#>
#> $weights
#> [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> [39] 1 1 1 1 1 1 1
# gs <- gs_prepare(
# "https://raw.githubusercontent.com/IanevskiAleksandr/sc-type/master/ScTypeDB_long.xlsx"
# )Universal marker format (long table)
Besides the wide ScType format below,
gs_prepare() also accepts the universal marker
format — a long table with one row per (cell type, marker)
pair, as used across the author’s biopipen tools. It is also
the default output of train_weights() and
find_markers().
The table can be a data.frame or a file
(.txt/.tsv, .csv,
.xlsx, .rds, or
.qs/.qs2 if the qs2 package is installed) with
the following columns:
-
cell_type(required): Cell type name. -
gene(required): Marker gene. -
direction(optional):positiveornegative(aliasespos/neg/+/-, case-insensitive). Negative markers penalize a cell type. -
weight(optional): Numeric magnitude of the marker weight. Combined withdirection: a positive marker gets weightabs(weight), a negative marker gets-abs(weight). Ifdirectionis missing, the signedweightis used as-is. If neither is given, the marker gets weight 1. Zero-weight markers are allowed. -
tissue(optional): Tissue type. One can passtissue_typetogs_prepare()to filter gene sets by tissue type. -
species,cancer(optional): Reserved filter columns (accepted and ignored bygs_prepare()). -
level(optional): Cell type level, as in theScTypeformat below.
Column names are matched case-insensitively and by alias
(celltype/type → cell_type;
marker/gene_symbol → gene;
sign → direction; tissueType →
tissue).
markers <- data.frame(
cell_type = rep(c("CD4 T", "CD8 T"), each = 3),
gene = c("CD3E", "CD4", "IL7R", "CD3E", "CD8A", "CD8B"),
direction = c("positive", "positive", "negative", "positive", "positive", "positive"),
weight = c(2.0, 1.5, 0.5, 2.0, 1.0, 1.0)
)
gs <- gs_prepare(markers)
gs$gene_sets[[1]]$`CD4 T`
#> $markers
#> [1] "CD3E" "CD4" "IL7R"
#>
#> $weights
#> [1] 2.0 1.5 -0.5Preparing your own gene sets (wide ScType format)
You can also prepare your own gene sets in the wide
ScType format. The gene sets should be a
data.frame or a tab-delimited file with the following
columns:
-
tissueType(optional): Tissue type. One can passtissue_typetogs_prepare()to filter gene sets by tissue type. -
cellName(required): Cell type name. -
geneSymbolmore1(required): Markers for the cell type. Multiple markers should be separated by,. One can use a suffix+to indicate that the marker is a positive marker, and-to indicate that the marker is a negative marker. Multiple+’s are allowed to indicate that the marker is a strong positive marker. Multiple-’s are allowed to indicate that the marker is a strong negative marker. For example,CD3E+++indicates thatCD3Eis a strong positive marker, andCD14---indicates thatCD14is a strong negative marker. -
geneSymbolmore2(required): Negative markers for the cell type. This column can be empty strings. This is kept for compatibility with ScType. No suffixes are allowed in this column. A marker in this column is the same as a marker in the previous column with a suffix-. -
level(optional): Cell type level. The level of thecellName. It must start from 1 and increase by 1. The final cell type consists of onecellNamefrom each level. -
nextLevels: Indication of possiblecellNames at the next level. Levels should be separated by;. ThecellNameat each level should be separated by,.- The format is
cellName1,cellName2;cellName3,cellName4;...for eachcellNameat the current level. - For example, for
CD4at level 1,nextLevelsNaive;Activatedindicates thatCD4should be followed byNaiveat level 2 andActivatedat level 3. - If the
nextLevelsis also specified forNaiveat level 2, then thecellNameat level 3 forCD4will be the intersection ofActivatedand thecellNames at level 3 forNaivelimited bynextLevelsforNaive. - If a level in
nextLevelsis empty, then thecellNames at that level will be allcellNames at the next level limited bynextLevelsof that level. -
!can be used to indicate that thecellNames at the next level should be excluded. For example,!Naiveindicates thatNaiveshould be excluded from thecellNames at the next level. - If
!is the only character in a level, then allcellNames at that level will be excluded.
- The format is
Any data.frame of markers (e.g. the output of
train_weights()) can be passed directly to
gs_prepare():
markers <- data.frame(
cellName = c("CD4 T", "CD8 T"),
geneSymbolmore1 = c("CD3E,CD4,IL7R", "CD3E,CD8A,CD8B"),
geneSymbolmore2 = c("", "")
)
gs <- gs_prepare(markers)