theislab / txsim

3 stars 0 forks source link

Add Data Simulation #84

Closed Lilly-May closed 9 months ago

Lilly-May commented 9 months ago

Changes proposed in this pull request:

An exemplary test run can be made using the following code:

import txsim as tx

sim = tx.simulation.Simulation()
sim.plot_kde()
sim.simulate_spatial_data('IL32')
sim.spatial_heatmap_gene('IL32', flavor="sum")

# simulate exact positions and plot cells and spots
sim.simulate_exact_positions(radius_range=(0.01, 0.05), cell_sampling_type='uniform', spot_sampling_type='uniform')
sim.spatial_cell_plot(s=10)
sim.spatial_spot_plot(s=2)

# look at spots in one grid field
adata_sp_subset = sim.adata_sp[(sim.adata_sp.obs['grid_x'] == 25) & (sim.adata_sp.obs['grid_y'] == 5)]
adata_sp_subset.uns['spots'] = sim.adata_sp.uns['spots'][sim.adata_sp.uns['spots']['cell_id'].isin(adata_sp_subset.obs_names)]
sim.spatial_spot_plot(adata_sp=adata_sp_subset)
LouisK92 commented 9 months ago

Okay I merge this for now as it's quite separate from all other parts in the package anyway. Will be important to make some adjustments at some point, but already useful in current state.