CellChat icon indicating copy to clipboard operation
CellChat copied to clipboard

netVisual_embeddingPairwise: error due to handling of 'pathway.remove'

Open ktessema opened this issue 4 years ago • 4 comments

Hi,

Thanks for the great package!

It seems like there's an issue in netVisual_embeddingPairwise related to removing pathways. Pathways to be removed are identified in the similarity matrix, where each pathway is represented multiple times (once for each dataset). Each pathway in pathway.remove meets the removal condition of colSums(similarity)==1 and is labeled accordingly (eg Pathway1--Dataset1).

However, when removing these from each individual dataset's probability matrix, the "--Dataset1" is dropped from the name and Pathway1 is subsequently removed from all datasets. As a result, the filtered similarity matrix (datasets combined) has a different number of rows compared to the sum of the rows of each dataset's filtered probability matrix. This results in an error:

Error in data.frame(x = Y[, 1], y = Y[, 2], Commun.Prob. = prob_sum/max(prob_sum), :
arguments imply differing number of rows: 235, 234

I think this will happen anytime a pathway is found in multiple datasets but did not meet the removal condition in all of those datasets.

I can think of two ways to resolve this: A. remove each pathway in pathway.remove from all datasets (in both the similarity matrix and in each individual probability matrix) B. only remove a pathway from an individual dataset's probability matrix if the pathway meets the removal condition in that particular dataset

I am not too familiar with the theory here, so I'm not sure what is best. For now I've edited the function to do option B and it's available here if anyone's interested.

Let me know if this makes sense or if I am misunderstanding!

ktessema avatar Aug 17 '21 04:08 ktessema

Same issue with netVisual_embeddingPairwiseZoomIn - both fix ideas should work for this one too.

ktessema avatar Aug 17 '21 05:08 ktessema

@iheartfoosball Thanks! Option B makes sense to me!

sqjin avatar Aug 21 '21 23:08 sqjin

Awesome, I sent a pull req :)

Hope you're doing well!

ktessema avatar Aug 24 '21 06:08 ktessema

@iheartfoosball Thank you so much! The edited function now works!

Matthew1309 avatar Aug 16 '22 00:08 Matthew1309