Coolgenome / iTALK

57 stars 22 forks source link

Color links by cell of origin #6

Closed PGmajev closed 4 years ago

PGmajev commented 5 years ago

Hello,

I am not sure whether I am just missing anything, but I would like to color the LR links in the chord Plot by the cell of origin.

So for example: I have pulmonary endothelial cells expressing a ligand that is known to interact with receptor in Pericytes. I would like to color that ligands link to the Pericytes by the color given to the endothelial cells. How would I do that?

I have tried to use the same vector as for the cell_col parameter, but that did not work.

alecorr commented 4 years ago

Hi,

Not sure if you're still looking for a solution but I think the line color vector needs to be the same length as the number of ligand-receptor pairs (ie number of lines in the LRPlot or number of rows in your dataframe).

So if you want to color the lines by the cell expressing the ligand, just use:

line_col <- cell_col[match(LRPlot_res$cell_from, names(cell_col))]

where cell_col is your cell colors vector and LRPlot_res is your dataframe.

Then just use the line_col vector for the link.arr.col argument in the LRPlot function

PGmajev commented 4 years ago

Thank you very much, that worked perfectly!