Add Gene Percentage¶
-
addGenesPerc()
Calculates the total percentage of (normalized) counts for a subset of selected genes.
addGenesPerc(
gobject,
expression_values = c("normalized", "scaled", "custom"),
genes = NULL,
vector_name = "gene_perc",
return_gobject = TRUE
)
Arguments¶
gobject |
giotto object |
expression_values |
expression values to use |
genes |
vector of selected genes |
vector_name |
column name as seen in pDataDT() |
return_gobject |
boolean: return giotto object (default = TRUE) |
Value¶
Giotto object if return_gobject = TRUE
. Otherwise it returns a vector with results.
Examples¶
data(mini_giotto_single_cell)
# select genes (e.g. Rpl or mitochondrial)
random_genes = sample(slot(mini_giotto_single_cell, 'gene_ID'), 5)
# calculate percentage of those selected genes per cells/spot
updated_giotto_object = addGenesPerc(mini_giotto_single_cell,
genes = random_genes,
vector_name = 'random_gene_perc')
# visualize result in data.table format
pDataDT(updated_giotto_object)
#> cell_ID nr_genes perc_genes total_expr leiden_clus cell_types
#> 1: cell_2 13 65 111.98320 3 cell C
#> 2: cell_7 15 75 115.73030 3 cell C
#> 3: cell_12 11 55 95.49802 1 cell A
#> 4: cell_15 12 60 99.94782 3 cell C
#> 5: cell_17 13 65 111.32963 2 cell B
#> 6: cell_30 11 55 96.64302 3 cell C
#> 7: cell_37 6 30 57.77777 2 cell B
#> 8: cell_40 9 45 82.84693 2 cell B
#> 9: cell_44 9 45 79.93838 2 cell B
#> 10: cell_53 9 45 82.40747 1 cell A
#> 11: cell_64 8 40 73.06345 1 cell A
#> 12: cell_74 11 55 93.04295 3 cell C
#> 13: cell_85 8 40 73.72574 1 cell A
#> 14: cell_86 14 70 115.75186 1 cell A
#> 15: cell_90 11 55 93.02181 1 cell A
#> 16: cell_95 6 30 59.55714 1 cell A
#> 17: cell_96 10 50 88.31757 1 cell A
#> 18: cell_107 16 80 130.62640 1 cell A
#> 19: cell_113 12 60 99.83100 2 cell B
#> 20: cell_118 14 70 117.63523 2 cell B
#> random_gene_perc
#> 1: 30.48
#> 2: 27.45
#> 3: 34.39
#> 4: 18.85
#> 5: 32.21
#> 6: 27.41
#> 7: 32.67
#> 8: 35.34
#> 9: 33.15
#> 10: 33.61
#> 11: 34.85
#> 12: 17.96
#> 13: 14.80
#> 14: 26.70
#> 15: 20.29
#> 16: 15.27
#> 17: 18.97
#> 18: 24.87
#> 19: 34.30
#> 20: 29.58