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

specific gene trends #25

Open
wangjiawen2013 opened this issue Nov 12, 2022 · 8 comments
Open

specific gene trends #25

wangjiawen2013 opened this issue Nov 12, 2022 · 8 comments

Comments

@wangjiawen2013
Copy link

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
Copy link
Owner

ShobiStassen commented Nov 12, 2022 via email

@ShobiStassen
Copy link
Owner

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

@wangjiawen2013
Copy link
Author

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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Author

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

@ShobiStassen
Copy link
Owner

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

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