KlugerLab / GeneTrajectory

R implementation of GeneTrajectory
https://www.nature.com/articles/s41587-024-02186-3
50 stars 9 forks source link

Visualize Gene bin score or plot #9

Open TreetoForest opened 6 months ago

TreetoForest commented 6 months ago

After studying the GeneTrajectory tutorial and R script in https://klugerlab.github.io/GeneTrajectory/articles/GeneTrajectory.html and github, I successfully completed the entire process. There are still some confusions that I don’t understand and can’t solve. Would I discuss this with you?

  1. About the “Gene bin score” Visualization Question 1 : Where can I get this gene order and expression statues in a ?

微信图片_20240508180556

The code is bellow:

Gene trajectory inference and visualization

gene_embedding <- GetGeneEmbedding(gene.dist.mat, K = 5)$diffu.emb

Extract 3 gene trajectories

gene_trajectory <- ExtractGeneTrajectory(gene_embedding, gene.dist.mat, N =6, t.list = c(4,7,7), K = 5) table(gene_trajectory$selected)

pdf("genes.pdf", width = 7, height = 5)

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))))

dev.off()

Extract the ordered list of genes along each gene trajectory

gene_list <- list()

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

str(gene_list) List of 3 $ : chr [1:43] "SASH1" "FCER2" "HLA-DQA2" "HLA-DQA1" ... $ : chr [1:55] "IFITM3" "MARCKSL1" "PNMA1" "IFIT2" ... $ : chr [1:153] "PID1" "NR4A1" "CIITA" "INSIG1" ...

str(gene_trajectory ) 'data.frame': 251 obs. of 9 variables: $ DM_1 : num 0.09108 0.06062 -0.00281 0.00107 0.07191 ... $ DM_2 : num -0.03209 -0.00684 0.0218 0.01764 -0.01563 ... $ DM_3 : num 0.03116 -0.00252 0.01149 -0.00252 0.00856 ... $ DM_4 : num -0.06191 0.01476 -0.00406 0.00517 -0.00964 ... $ DM_5 : num 0.03953 -0.02272 0.01417 0.01583 -0.00482 ... $ selected : chr "Trajectory-2" "Trajectory-2" "Trajectory-1" "Trajectory-1" ... $ Pseudoorder1: num 0 0 29 4 0 0 0 20 0 0 ... $ Pseudoorder2: num 55 42 0 0 46 51 41 0 40 0 ... $ Pseudoorder3: num 0 0 0 0 0 0 0 0 0 129 ...

Question 2 : How to display it split.by in groups? like in a and c in this figure.

Question 3 : How to analyses it to different Stages status?

  1. About the “Gene bin plot” Visualization 微信截图_20240508182105

in e , I have a list of markers of interest like Sox2, they have highers pseudoorder values.

How can I see their trajectory like e , Gene bin-1 to Gene bin -7. I just want to display the markers of interest.