pogorely / ALICE

Detecting TCR involved in immune responses from single RepSeq datasets
GNU General Public License v3.0
25 stars 13 forks source link

Igraph visualization methods #18

Open leeanapeters opened 1 year ago

leeanapeters commented 1 year ago

Hi, thank you for the great package!

I was wondering if you could provide some more information on how you used Igraph to visualize the Alice output?

Thanks!

Leeana

pogorely commented 1 year ago

Hi Leeana,

1) Use a igraph_from_seqs function from ALICE R script. You input sequences and maximum number of mismatches and the function outputs igraph object. Here is an example in R console (you make a similarity network on CDR3 seqs and output it into the file):

gr<-igraph_from_seqs(mydata$CDR3.amino.acid.sequence, max_errs=1); plot(gr) write.graph(gr,file=“gr.gml”,format=“gml”);

2) Small note and a trick: in our experience it makes more sense to compare TCR sequences allowing only mismatches in CDR3 and disallowing any mismatches in V segment (which encodes for CDR1 and CDR2). The easiest way to do that is to make the similarity network on concatenated CDR3 and V repeated several times.

source(“ALICE.R”); gr<-igraph_fromseqs(paste0(mydata$CDR3.amino.acid.sequence,””, mydata$bestVGene, mydata$bestVGene) max_errs=1); write.graph(gr,file=“gr.gml”,format=“gml”)

Resulting gr.gml file could be further opened and visualized with GUI software for network visualization, we use gephi (but you could also try cytoscape and others). There is no code necessary at this step, everything is done through the GUI. What we normally do with gephi is layout the network (e.g. with force atlas 2 algorithm with prevent overlap option), make node sizes proportional to degree, color nodes according to metadata, such as donor ids/conditions etc. You could add any metadata you want to the network in R, see the example for hypothetical “donor" column and then use this attribute to color vertices in gephi:

gr <- set.vertex.attribute(gr, 'donor_id', V(gr), mydata$donor)
write.graph(gr,file=“gr.gml”,format=“gml”)

Hope that helps!