ShobiStassen / VIA

trajectory inference
https://pyvia.readthedocs.io/en/latest/
MIT License
76 stars 20 forks source link

specific gene trends #25

Open wangjiawen2013 opened 1 year ago

wangjiawen2013 commented 1 year ago

Hi, Are there any ways to plot gene expression along only one or more lineages using via.get_gene_expression? It's similar to palantir function compute_gene_trends(pr_res, gene_exprs, lineages=None, n_jobs=-1), where lineages: Subset of lineages for which to compute the trends

ShobiStassen commented 1 year ago

Hi again,

Yes we can do that, I'll make the changes by Monday and update the git and pip versions

On Sat, 12 Nov 2022, 13:31 jiawen wang, @.***> wrote:

Hi, Are there any ways to plot gene expression along only one or more lineages using via.get_gene_expression? It's similar to palantir function compute_gene_trends(pr_res, gene_exprs, lineages=None, n_jobs=-1), where lineages: Subset of lineages for which to compute the trends

— Reply to this email directly, view it on GitHub https://github.com/ShobiStassen/VIA/issues/25, or unsubscribe https://github.com/notifications/unsubscribe-auth/AISI4SEOKRFH6K5W2C64JADWH4TT5ANCNFSM6AAAAAAR6E2SZE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

ShobiStassen commented 1 year ago

hi, just made the changes and are available on git/pip if you want to update. let me know if it works

wangjiawen2013 commented 1 year ago

Great, it works! And can we set a list of user defined terminal states ? Now the terminal states are generated automatically.

This is what palantir does: terminal_states = pd.Series(['DC', 'Mono', 'Ery'],index=['Run5_131097901611291', 'Run5_134936662236454', 'Run4_200562869397916']) start_cell = 'Run5_164698952452459' pr_res = palantir.core.run_palantir(ms_data, start_cell, num_waypoints=500, terminal_states=terminal_states.index)

ShobiStassen commented 1 year ago

hi, that would be useful if you want to 'overwrite' the autodetection. we can do a fairly quick fix on that but would need until next week when we have a little more time. thanks for the useful suggestions

ShobiStassen commented 1 year ago

hi @wangjiawen2013 this should be fixed now - let me know if it works for you you can specify user_defined_terminal_group=['pDC','MONO1','MEGA1'] - these must correspond to labels in true_label paramter, or you can give user_defined_terminal_cell=[] (with single cell indices as a list of integers) when you initialize v0=VIA()

you can also selectively plot lineage branch probabilities in draw_sc_lineage_probability() or get_gene_expression() by setting marker_lineages = [] with the suitable terminal lineage clusters. draw_sc_lineage_probability(v0, embedding=tsnem, marker_lineages=[2,4,6,9]) get_gene_expression(via0=v0, gene_exp=df_magic, cmap='rainbow', marker_genes=marker_genes,marker_lineages=[2,4,6,9]) Randomseed is also now fixed to keep pt stable

wangjiawen2013 commented 1 year ago

Hi, Good feature ! will this feature introduce a bug when there are only terminal state ? Becuase I met this error: In [57]: via.draw_sc_lineage_probability(via_coarse=v0, via_fine=v0,embedding=embedding,scatter_size=size) 2022-12-19 19:25:32.144658 Marker_lineages: [6] 2022-12-19 19:25:32.157409 The number of components in the original full graph is 1 2022-12-19 19:25:32.157447 For downstream visualization purposes we are also constructing a low knn-graph 2022-12-19 19:25:33.445752 Check sc pb [1.] /home/wangjw/programs/miniconda3/envs/py37/lib/python3.7/site-packages/pyVIA/plotting_via.py:500: RuntimeWarning: Couldn't reach some vertices at src/paths/unweighted.c:440 path_orange = G_orange.get_shortest_paths(via_fine.root[ii], to=fst_i)[0]

TypeError Traceback (most recent call last)

in ----> 1 via.draw_sc_lineage_probability(via_coarse=v0, via_fine=v0,embedding=embedding,scatter_size=size) ~/programs/miniconda3/envs/py37/lib/python3.7/site-packages/pyVIA/plotting_via.py in draw_sc_lineage_probability(via_coarse, via_fine, embedding, idx, cmap_name, dpi, scatter_size, marker_lineages, fontsize) 524 525 if fig_nrows ==1: --> 526 plot_sc_pb(axs[c], fig, embedding, p1_sc_bp[:, loc_ts_current], ti= str(ts_current)+'-'+str(majority_composition), cmap_name=cmap_name, scatter_size=scatter_size, fontsize=fontsize) 527 528 else: TypeError: 'AxesSubplot' object is not subscriptable
wangjiawen2013 commented 1 year ago

Perhaps all the function that use plt.subplots() will lead to this issue when there are only one plot.

ShobiStassen commented 1 year ago

hi, i fixed this bug in draw_sc_lineage_probability() so that you can also plot just one single lineage