rnabioco / djvdj

An R package to analyze single-cell V(D)J data
https://rnabioco.github.io/djvdj
Other
24 stars 4 forks source link

plot_diversity output #141

Closed Ahmedalaraby20 closed 6 months ago

Ahmedalaraby20 commented 8 months ago

So I used

PILTcells |> plot_diversity(data_col = "cdr3", cluster_col = "subset",chain = "TRA" , downsample = T, method  = div_fns,alpha    = 0.5, linetype = 2, color    = "black")+  theme(strip.text = element_text(face = "bold"), axis.text.x = element_text(size = 10, angle = 90,  hjust=1))
ggsave("diversity TCRa subsets.svg", width = 10, height = 7.5, units = "cm")

For some reason, the output plot is so annoying to work with when I import it into Inkscape. It looks like there are as many bars as there are cells

Screenshot from 2024-02-08 08-39-55

I can do this ggplot it but it is not ideal

xx <- table(res@meta.data[["cdr3_simpson_diversity"]])
x <- table(res@meta.data[["subset"]])

Thanks again for this amazing tool :D

sheridar commented 7 months ago

Hi @Ahmedalaraby20, sorry about the delayed response. I haven't been able to reproduce your issue, can you send me the meta.data from your object?

Ahmedalaraby20 commented 7 months ago

Hey, Please find attached the metadata RDS meta.zip

sheridar commented 6 months ago

Really sorry about the delayed response, using your object I still haven't been able to reproduce the issue, here is the code I tried, and I attached a screenshot from Inkscape. It might be good to try re-installing djvdj from github and then re-running. Is the code/data you sent the exact same code/data.frame used to generate your previous plot?

div_fns <- c(
  simpson = abdiv::simpson,
  shannon = abdiv::shannon,
  pielou  = abdiv::pielou_e
)

obj <- readRDS("~/Projects/djvdj/data-old/ahmed/2024-02-26_meta/meta.rds")

set.seed(42)

obj |>
  plot_diversity(
    data_col    = "cdr3",
    cluster_col = "subset",
    chain       = "TRA",
    downsample  = TRUE,
    method      = div_fns,
    alpha       = 0.5,
    linetype    = 2,
    color       = "black"
  ) +
  theme(
    strip.text = element_text(face = "bold"),
    axis.text.x = element_text(size = 10, angle = 90,  hjust = 1)
  )

ggsave("issue_141_plot.svg", width = 10, height = 7.5, units = "cm")

issue_141_inkscape

Ahmedalaraby20 commented 6 months ago

@sheridar Thanks a lot