Removing duplicate edges?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hey all, very new to matlab and am trying to use it to generate protein-protein interaction networks. The first dataset I used went through just fine, but I'm having some trouble with my second one.
Gene1 'MAP2K4' 'MYPN' 'ACVR1' 'GATA2' 'RPA2'
Gene2 'FLNC' 'ACTN2' 'FNTA' 'PML' 'STAT3'
I have two cell arrays like shown above, where spot 1 in Gene1 interacts with spot 1 in Gene2 (forms an edge). The first time I did this it was easy to just use the graph function >> graph(Gene1,Gene2). But with my second dataset I have double edges(usually flipped around), and when I go to use the graph function I get the error "matlab.internal.graph.MLGraph" and am not sure how to go about removing them.
If you need any more info from me I will be happy to provide it, just starting out and not sure how to say it all quite yet though :)
2 comentarios
Respuestas (3)
Christine Tobler
el 2 de Nov. de 2016
If your duplicates are always one that is A->B and another B->A, Alexandra's elegant solution will work very well.
If you have duplicate edges that are exactly the same (say A->B and A->B appears twice), you would need some workaround as unique(..., 'rows') is not supported for cell arrays. The simplest is probably to cast your cell array to a categorical, apply unique(..., 'rows'), and cast back to cellstr. Then, you can apply Alexandra's solution to this new array.
A = [Gene1(:), Gene2(:)];
uniqueA = cellstr(unique(categorical(A), 'rows'));
d = digraph(uniqueA(:,1), uniqueA(:,2));
m = full(adjacency(d));
g = graph(m|m',d.Nodes);
0 comentarios
Alexandra Harkai
el 25 de Oct. de 2016
A graph-driven workaround could be:
d = digraph(Gene1,Gene2);
m = full(adjacency(d));
g = graph(m|m',d.Nodes);
This creates a digraph with edges A->B and B->A being different directed edges, then making sure we get a symmetric adjacency matrix out of it, and smashing on the Node names we got from the original digraph.
This of course depends how fast and large you need this to be. This may not be the most efficient solution.
0 comentarios
Ver también
Categorías
Más información sobre Genomics and Next Generation Sequencing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!