Closed yitengfei120011 closed 10 months ago
Hi @yitengfei120011,
Thank you for your inquiry. I am not sure I fully understand the question. Why would you expect all terminal cell states to have the same gene expressions? Since different terminal refer to different cell states that are only defined through their gene expression, it seems their gene expressions should differ by definition.
For all visual customization such as color range and positioning of the color bar you can use its argument
cbkwargs : dict
Additional keyword arguments for matplotlib.pyplot.colorbar.
**kwargs : dict
Additional keyword arguments for matplotlib.pyplot.matshow.
s. matplotlib colorbar and matplotlib matshow. For example
palantir.plot.plot_gene_trend_heatmaps(ad, genes, vmin=-1, vmax=1, cbkwargs=dict(shrink=.5))
plt.show()
fixes the color gradient to cover a value range between -1 and 1, and reduces the size of the color bar.
Please let me know if this resolves the issue.
My question is why is the same gene expressed differently in different lineages? eg: as shown with 'CD34' in the picture.
Hi @yitengfei120011,
As the left hand side of this plot does relate to the same stem cell state, it is indeed expected to show the approximately same gene expression values for the same gene. And indeed, looking at the color bar to the right of these plots reveals that colors of CD34 correspond to the same expression value of approximately 1 in both linages. The reason for the different scaling in the Ery linage is the high expression reached by MPO towards the terminal. If you want to fix the scale to the same values (e.g., -3 to 2) you can use the vmin
and vmax
parameters like so:
palantir.plot.plot_gene_trend_heatmaps(ad, genes, vmin=-3, vmax=2)
plt.show()
Does that resolve the issue?
hi, my palantir version is 1.2
palantir.plot.plot_gene_trend_heatmaps(ad, genes, vmin=-3, vmax=2) not work .
Can I succeed without changing another version ?
Hi @yitengfei120011,
Unfortunately, this is not possible with Palantir v1.2. I would recommend updating, e.g., with
python -m pip install --no-deps --upgrade palantir
or you can copy the new function from here: https://github.com/dpeerlab/Palantir/blob/906bddfca51ae2891a05064b93210875f3ec63b0/src/palantir/plot.py#L1583-L1663
Also note that by default z-score scaling is applied. This means the gene expression values are rescaled to nicely use the whole color spectrum. This is a common practice for heat maps to preserve contrast of each row. If you do not want any scaling and leave the gene expressions as is you can pass scaling="none"
to the function, like so:
palantir.plot.plot_gene_trend_heatmaps(ad, genes, scaling="none")
plt.show()
Hi, When I unify the ruler , like the gene 'Tgfbr1' , the start point of the gene has different expression levels, how to explain it ?
Hi @yitengfei120011,
Thank you for your question! Is this plot done with the scaling="none"
:
palantir.plot.plot_gene_trend_heatmaps(ad, genes, scaling="none")
plt.show()
The default scaling (zscore
) adjusts the levels such that the whole color spectrum is used, which is a common practice for heatmaps. e.g., see "zscore" in seaborn.clustermap.
Without scaling, the initial value on the heatmap is influenced by the selection of cells for each branch. This can cause discrepancies if high-expressing cells near the start point are unevenly distributed between the two branches. To better understand this, I recommend examining the branch selection using palantir.plot.plot_branch_selection(ad)
and comparing gene expression across the UMAP plot. This approach helps identify if certain cells are disproportionately influencing the trend.
For a more granular analysis, inspecting the raw vs. smoothed gene expression trends can be enlightening. Here’s how you can visualize this for specified branches:
palantir.plot.plot_trend(ad, "GCAGGCTAGAGGTCAC-1-FDEHP", "Tgfbr1", color="celltype")
plt.show()
palantir.plot.plot_trend(ad, "GTAACCACAGTTGTTG-1-FDEHP", "Tgfbr1", color="celltype")
plt.show()
If your data doesn’t include celltype
annotations yet, simply omit or modify the color="celltype"
argument accordingly.
I hope this clarifies your query. Please don’t hesitate to reach out if you have more questions or need further assistance. I'm here to help!
hi, Before performing the palantir.plot.plot_trend() drawing ,the gene trends I calculated are as follows . According to the figure above, the expression level of the start point is different, and the value should be without scaling. Does the column '0.000000' in the figure represent the expression of the starting point cell? Or does it represent the expression level of the nearby cell set near the starting point cell ?
Hi @yitengfei120011,
Indeed, the observed gene trend discrepancies are influenced by the expression levels of all cells within similar pseudotime ranges in their respective branches. Generally, branches at pseudotime 0 select a comparable set of cells. The marked difference between the two branches in your case suggests a potential issue with cell selection, possibly due to an outlier cell present in one branch but not the other. I recommend revisiting the cell selection process. Utilizing palantir.plot.plot_branch_selection(ad)
and overlaying gene expression on the UMAP plot could provide valuable insights.
To further investigate the source of these differences, examining the specific gene expression trends together with the cell-wise gene-expression levels could be helpful. This can be achieved with the following commands, which plot both and may pinpoint the contributions to the observed gene trend:
palantir.plot.plot_trend(ad, "GCAGGCTAGAGGTCAC-1-FDEHP", "Tgfbr1", color="celltype")
plt.show()
palantir.plot.plot_trend(ad, "GTAACCACAGTTGTTG-1-FDEHP", "Tgfbr1", color="celltype")
plt.show()
These plots could identify the cells driving the trend computation. If your dataset lacks celltype
annotations, adjust or omit the color="celltype"
parameter as necessary.
I'm keen to assist further, so please don't hesitate to share these plots or ask additional questions.
eg: https://nbviewer.org/github/dpeerlab/Palantir/blob/master/notebooks/Palantir_sample_notebook.ipynb ,
palantir.plot.plot_gene_trend_heatmaps(ad, genes) plt.show() Shown in Fig , 'CD34' gene expressed differently in different terminal states,