Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with coloring dots using pointCol in plotSmoothers #266

Open
beazors opened this issue Oct 1, 2024 · 1 comment
Open

Problem with coloring dots using pointCol in plotSmoothers #266

beazors opened this issue Oct 1, 2024 · 1 comment

Comments

@beazors
Copy link

beazors commented Oct 1, 2024

Hello, I'm writing because I think there is a bug in the argument that specifies point colors in plotSmoothers. I have checked to make sure I am running the most up-to-date version of TradeSeq.

Here is my code:

#accessing lineage info for cells
lincells<-sce@colData@listData$tradeSeq$dm

#Creating a vector to hold the lineage assignments for each cell
vector<-as.data.frame.numeric(rep("0",nrow(lincells)))

  for (a in 1:nrow(lincells)) {
    if (lincells[a,4]==1) {
      vector[a,1]<-"1"
    } else if (lincells[a,6]==1) {
      vector[a,1]<-"2"
    } else if (lincells[a,8]==1) {
      vector[a,1]<-"3"
    } else if (lincells[a,10]==1) {
      vector[a,1]<-"4"
    } else if (lincells[a,12]==1) {
      vector[a,1]<-"5"
    }
  }

# adding vector of lineage assignments to the prior object
newlincells<-cbind(lincells,vector)
colnames(newlincells)[ncol(newlincells)]<-"lineage"

#custom color palette to test
colsTS=c("magenta","darkgrey" ,"blue", "red", "green")

#plot with new colors
c<-plotSmoothers(sce, counts, gene=gene_name,pointCol=colsTS[as.numeric(newlincells$lineage)],curvesCols=colsTS)+#labs(title=paste(gene_name))+
  theme(plot.title = element_text(hjust = 0.5))

#plot with default viridis
d<-plotSmoothers(sce, counts, gene=gene_name)+#labs(title=paste(gene_name))+
  theme(plot.title = element_text(hjust = 0.5))

#comparison
plot_grid(c,d)

This produces the following plot:

test1

You can see that the curves are successfully colored with colors from the custom palette, but the dots are not. Puzzlingly, there are colors in the dots (and in the legend) that are not in the color palette I provided. I tried again using hex codes instead, and got a similar result:

colsTS=c("#FF00FF","#999999" ,"#0000FF", "#FF0000", "#66FF33")

test2

@beazors
Copy link
Author

beazors commented Oct 3, 2024

For anyone else struggling with changing the colors of curves or points, I was able to use the ggplot scale_colour_manual to do this instead. See the example code here: https://rdrr.io/github/statOmics/tradeSeq/man/plotSmoothers.html

For the developers: the problem of "pointCol" not working as intended, when provided "a vector of length equal to the number of cells" as documentation suggests, seems to be real. I have provided both character and numeric vectors that don't throw errors, but the color scheme of the points seems to be picked without regard for what the input actually says (e.g. hex codes, color names).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant