Hi,
Usually, when we are trying to plot the marker intensities in a heat map or feature plot, they have strongly skewed distributions with varying ranges of expression, thus making it difficult to distinguish between the negative and positive cell populations. It is common practice to transform marker intensities with a cofactor. For example like below but this gets quantile while I need binary
library(matrixStats)
rng <- colQuantiles(expr, probs = c(0.01, 0.99))
expr01 <- t((t(expr) - rng[, 1]) / (rng[, 2] - rng[, 1]))
expr01[expr01 < 0] <- 0
expr01[expr01 > 1] <- 1
Assuming I have a list of 10 genes A,B,C,D,E,F,G,H,I and J
. I want to set expression of each of them to 0.1 so when all of 10 genes are exist in a cluster of cells (showing by heat map or feature plot) I obtain 1
(10*0.1)
, when none of them are exist I obtain 0
, when 9
of them exist in an expression matrix I obtain 0.9
, so on. I mean converting expression values to 0
or 1
(off, on) only to be able distinguish cell populations. But I don't have any idea how to do that, any help please?
Okay, but please show the formatting of your data. In which data-type is your gene list stored?; in which data-type is your cluster of cells stored?
Thanks a lot, for example we have cells 1 to 3 and genes A to E
Based on a threshold the ratio of the expression of genes
A,B,C,D,E in CELL1 is 0.4 (2/5), 0.8 in CELL2 (4/5) and 0.6 in CELL3 (3/5).
So when in heat map or feature plot we are colouring these genes in these cells, CELL1, CELL2 and CELL3 would show distinct colours not noisy. 0 and 1 are not nessacarily numbers rather each binary phase can gets this matrix but I am not sure how produce this matrix. By codes provided above I produce such a matrix and by colSum/number of genes I have a vector of ratios in each cell likeNow I want to color the cells in my seurat object based this vector but nothing in googling I am finding for that
Maybe this practical example will help:
Thanks a lot, I think we are somehow close to the solution; You know, I can not put a distinct threshold for each cell in a big matrix as you defined for 3 cells. matrixStats package either by colQuantiles, colRanges or colRanks functions returns values between 0 and 1 while I need either 0 or 1. Now, my problem is, given an expression matrix how change your or below code or provide a new function that transform my matrix to 0 and 1 values (100% binary)
https://ibb.co/jPDRqU