How can I manage to have my vertex.size reflecting my expansion.size?


I am new in igraph and I am trying to represent connection between sequences I have in one or more cells (expansion size) and I color them according to their cell biological populations. In the test_ss_NA table I have a column called expansion.

cdr3b <- test_cdr3b$trb.cdr3 (sequences)
nkt.seqs  <- unique(cdr3b)
nkt.graph <- graph.empty(n = length(nkt.seqs), directed=F)
nkt.dist <- stringdist::stringdistmatrix(nkt.seqs, nkt.seqs, method="lv")
nkt.graph <- add.edges(nkt.graph, t(which(nkt.dist <= 1, arr.ind=T)))
nkt.graph <- igraph::simplify(nkt.graph)

colors <- test_ss_NA %>% 
  mutate(color= ifelse(hto.type == "umft84", "#d11141",
                       ifelse(hto.type == "unmapped",'#12CBC4', "grey"))) %>%

V(nkt.graph)$color <- colors

plot(delete.vertices(simplify(nkt.graph), degree(nkt.graph)==0), vertex.size=3, vertex.label= NA , edge.color = "black")

This code above work for the color but when I add this for the size

sizes <- test_ss_NA$expansion
V(nkt.graph)$size <- sizes

nothinh work anymore

Could someone help me for this?

Could you perhaps be more specific about what doesn’t work anymore? Otherwise it’s difficult for people to try to answer your question.

Even better if you would be able to post a self-contained minimal reproducible example that we can copy-paste to run and see the problem you are encountering.

To be more specific, add (the result of) dput(cdr3b) after the first line, so that we know your source data. If cd3rb is quite large, then the first 10 lines are sufficient.

It is also good practice to include the required libraries.