ncborcherding / escape

Easy single cell analysis platform for enrichment
https://www.borch.dev/uploads/screpertoire/articles/running_escape
MIT License
143 stars 20 forks source link

Question about NES #119

Closed alicekao1118 closed 1 month ago

alicekao1118 commented 1 month ago

Hi,

Currently I'm trying to geneate the normalized enrichment score (NES) and I'd like to confirm my understanding between different functions before I go ahead to do my analysis, particularly ssGSEA and UCell.

For ssGSEA, it's the the maximum value of the random walk statistic (without adjusting/ normalizing by gene set size).

For UCell, I'm not sure if it's the above ssGSEA enrichment score normalized by the gene set size or just the Mann-Whitney U statistic.

So I do not know which function exactly would give me NES.

Please correct me if anything is wrong. Thank you!

Alice

ncborcherding commented 1 month ago

Hey Alice,

Normalized enrichment score (NES) in the traditional sense of GSEA is the ES / mean(ES across permutations). There is no permutations for any of the approaches in escape and so there is no NES outputted.

There is a normalization function in escape.matrix() and runEscape() that takes the ES and divides by the number of features present per gene set (or other vector using scale.factor) to produced a normalized enrichment score output. Sorry this might be confusing - I tried to avoid "NES".

You are correct for UCell, the ES is derived from the Mann-Whitney U statistic.

Hope that helps and let me know if you have any other questions.

Nick

alicekao1118 commented 1 month ago

Hi Nick,

Thanks for the quick reply. I tried escape.matrix() with normalize and not normalized, but the output seems to be the same.

ESH.normalized = escape.matrix(RTFAK, method="ssGSEA", gene.sets = gene.sets.H, min.size=15, groups=1000, normalize = TRUE)
ESH.normalized[1:5, 1:5]

                HALLMARK-ADIPOGENESIS HALLMARK-ALLOGRAFT-REJECTION HALLMARK-ANDROGEN-RESPONSE
Pt9_Pre1_217629              14094.57                     8572.295                   14518.38
Pt9_Pre1_249343              14333.48                     8753.041                   14865.47
Pt9_Pre1_515715              14981.00                     8859.232                   16144.70
Pt9_Pre1_56945               15157.72                     9037.871                   15428.03
Pt9_Pre1_500645              14533.56                     7870.661                   12414.76
                HALLMARK-ANGIOGENESIS HALLMARK-APICAL-JUNCTION
Pt9_Pre1_217629              7012.865                 9916.607
Pt9_Pre1_249343              7828.812                10939.784
Pt9_Pre1_515715             10846.619                12344.452
Pt9_Pre1_56945               7789.955                11569.822
Pt9_Pre1_500645              6424.644                10503.131

ESH.not.normalized = escape.matrix(RTFAK, method="ssGSEA", gene.sets = gene.sets.H, min.size=15, groups=1000, normalize = FALSE)
ESH.not.normalized[1:5, 1:5]

                                HALLMARK-ADIPOGENESIS HALLMARK-ALLOGRAFT-REJECTION HALLMARK-ANDROGEN-RESPONSE
Pt9_Pre1_217629              14094.57                     8572.295                   14518.38
Pt9_Pre1_249343              14333.48                     8753.041                   14865.47
Pt9_Pre1_515715              14981.00                     8859.232                   16144.70
Pt9_Pre1_56945               15157.72                     9037.871                   15428.03
Pt9_Pre1_500645              14533.56                     7870.661                   12414.76
                HALLMARK-ANGIOGENESIS HALLMARK-APICAL-JUNCTION
Pt9_Pre1_217629              7012.865                 9916.607
Pt9_Pre1_249343              7828.812                10939.784
Pt9_Pre1_515715             10846.619                12344.452
Pt9_Pre1_56945               7789.955                11569.822
Pt9_Pre1_500645              6424.644                10503.131