Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Make LR contribution comparable across pathways, sources and targets #700

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Puriney
Copy link

@Puriney Puriney commented Sep 26, 2023

Motivation:

Find the LR contributions that are comparable across pathways, sources, and targets. After using this PR, users can rank the LR from various pathways. Importantly, the contribution value is 'global' and comparable across various pathways, sources, and targets.

For example, now I am examing LRs from multiple pathways signaling = c('ICOS', 'PD-L1', 'TIGIT', 'SELE').
image

Problem:

For the same LR, the contributions are different depending on the selected pathways, sources and targets. Because the contributions are 'relative'. See line:

prob <-(prob-min(prob))/(max(prob)-min(prob))

Solution:

I modified the original netAnalysis_contribution into another function netAnalysis_contribution_allLR. It has two improvements: 1) comparing multiple pathways, and 2) avoiding the relative prob.

Misc:

  • The new function generates the same result based on a single pathway and all sources and targets, in my own dataset. This probably confirms the new function works.
  • The new function just spreads this idea. Feel free to edit and incorporate into the original function if you find the idea of this PR is helpful.
  xx = CellChat::netAnalysis_contribution(
    cellchat, signaling = 'ICOS', return.data = T, 
    sources.use = levels(cellchat@idents), 
    targets.use = levels(cellchat@idents))
  yy = CellChat::netAnalysis_contribution_allLR(
    cellchat, signaling = 'ICOS', return.data = T, 
    sources.use = levels(cellchat@idents), 
    targets.use = levels(cellchat@idents))
  
  head(xx)
  head(yy)
>   head(xx)
$LR.contribution
                     name contribution
ICOSL_ICOS   ICOSL - ICOS   0.46771954
ICOSL_CTLA4 ICOSL - CTLA4   0.43755524
ICOSL_CD28   ICOSL - CD28   0.09472522

$gg.obj

>   head(yy)
$LR.contribution
                     name contribution
ICOSL_ICOS   ICOSL - ICOS 2.646738e-07
ICOSL_CTLA4 ICOSL - CTLA4 2.476044e-07
ICOSL_CD28   ICOSL - CD28 5.360325e-08

$gg.obj
image

Unresolved issue:

I did not use the vertex.receiver para and I did not find a demo for it. I am not sure how to handle the normalization part for the 'hierarchy1' and 'herarchy2'.

See the code block in: https://github.com/Puriney/CellChat/blob/25fac78c144c831a01eddb239537826ed17979f3/R/analysis.R#L338-L344

Puriney and others added 3 commits September 26, 2023 11:39
Customized version of the function netAnalysis_contribution with the goal of 1) comparing all possible pathways and 2) avoiding relative prob.
Add back the signaling param to be comparable with the netAnalysis_contribution.
#prob <-(prob-min(prob))/(max(prob)-min(prob)) # this is the relative prob

if (is.null(vertex.receiver)) {
pSum <- apply(prob, 3, function(pmat) {sum(pmat) / length(unique(c(sources.use, targets.use)))})
Copy link
Author

@Puriney Puriney Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With more sources/targets, the original sum will always be higher; so the number of sources/targets should be somehow adjusted. Here, I just divide, but there could be a better solution.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant