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

how to plot the label of genes in 3d plot? #7

Open
feanaros opened this issue Apr 22, 2024 · 3 comments
Open

how to plot the label of genes in 3d plot? #7

feanaros opened this issue Apr 22, 2024 · 3 comments

Comments

@feanaros
Copy link

I don't understand how to determine if a gene is in the end of trajectory, I have a list of markers of interest. they have highers pseudoorder values. ho can I see if they are at the end of the trajectory? and to which cell types they belong to?

@RihaoQu
Copy link
Collaborator

RihaoQu commented Apr 30, 2024

Hi, the following code might be helpful to highlight the location of specific gene markers.

#After getting the gene embedding and extracting gene trajectories
gene_labels <- paste("-----", rownames(gene_embedding))
names(gene_labels) <- rownames(gene_embedding)
genes_selected <- c("CCR2", "ICAM2", "FCGR3A",  "SELL", "C1QA", "C1QB",
                    "CD1C", "CLEC10A", "CD2", "CD72", "CCR5",
                    "PKIB", "RETN", "CLEC5A", "CSF1R") #Your genes of interest
gene_labels[names(gene_labels) %notin% genes_selected] <- ""
par(mar = c(1.5,1.5,1.5,1.5))
scatter3D(gene_embedding[,1],
          gene_embedding[,2],
          gene_embedding[,3],
          bty = "b2", colvar = as.integer(as.factor(gene_trajectory$selected))-1,
          main = "trajectory", pch = 19, cex = 1, theta = 45, phi = 0,
          col = ramp.col(c(hue_pal()(3))))
text3D(gene_embedding[,1],
       gene_embedding[,2],
       gene_embedding[,3],  labels = gene_labels,
       add = T, colkey = FALSE, cex = 0.5)

If you want to extract the full list of genes following their order along each gene trajectory, the following code might help.

gene_list <- list()
for (i in 1:3){
  message(paste0("Trajectory-", i))
  gene_trajectory_sub <- gene_trajectory[which(gene_trajectory$selected == paste0("Trajectory-", i)),]
  genes <- rownames(gene_trajectory_sub)[order(gene_trajectory_sub[, paste0("Pseudoorder", i)])]
  message(paste(rev(genes), collapse = ", "))
  gene_list[[i]] <- genes
}

@feanaros
Copy link
Author

Ho! Thank you very much! Just another question Is: Is It possibile to color the trajectory by Cell types (clusterization generates by Seurat?) or Is It Just a gene ordering so It Is not possibile to extract the Cell barcode?

@RihaoQu
Copy link
Collaborator

RihaoQu commented Apr 30, 2024

Yes, the gene trajectories cannot be directly colored by cell types since they do not match cell barcodes. As an alternative, you can correspond each trajectory to specific cell populations based on gene bin plots over the cell embedding.

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

2 participants