@@ -17,16 +17,16 @@ Functions to read the data in the correct format are available for common file f
1717 import ovrlpy
1818
1919 # Define analysis parameters for ovrlpy
20- kde_bandwidth = 2 # The smoothness of the kernel density estimation (KDE)
21- n_expected_celltypes = 20 # Number of expected cell types in the data
20+ kde_bandwidth = 2.5 # smoothness of the kernel density estimation (KDE)
21+ n_components = 20 # number of principal components, depends on the data complexity
2222
2323 # Load your spatial transcriptomics data from a CSV file
2424 coordinate_df = pd.read_csv(' path/to/coordinate_file.csv' )
2525
2626
2727 In this step, we load the dataset and configure the model parameters, such as
2828`kde_bandwidth ` (to control smoothness) and
29- `n_expected_celltypes ` (to set the expected number of cell types ).
29+ `n_components ` (to set the number of prinicpal components that will be used ).
3030
31312. Fit the ovrlpy Model
3232_______________________
@@ -36,17 +36,13 @@ Fit the **ovrlpy** model to generate the signal integrity map.
3636.. code-block :: python
3737
3838 # Fit the ovrlpy model to the spatial data
39- integrity, signal, visualizer = ovrlpy.run (
40- df = coordinate_df,
39+ dataset = ovrlpy.Ovrlp (
40+ coordinate_df,
4141 KDE_bandwidth = kde_bandwidth,
42- n_expected_celltypes = n_expected_celltypes
42+ n_components = n_components,
43+ n_workers = 4 , # number of threads to use for processing
4344 )
44-
45- This function generates:
46-
47- - **integrity **: The signal integrity map.
48- - **signal **: The signal map representing the strength of spatial expression signals.
49- - **visualizer **: A visualizer object that helps to plot and explore the results.
45+ dataset.analyse()
5046
5147 3. Visualize the Model Fit
5248__________________________
@@ -55,8 +51,7 @@ Once the model is fitted, you can visualize how well it matches your spatial dat
5551
5652.. code-block :: python
5753
58- # Use the visualizer object to plot the fitted signal map
59- visualizer.plot_fit()
54+ fig = ovrlpy.plot_pseudocells(dataset)
6055
6156 This plot gives you a visual representation of the models fit to the spatial transcriptomics data.
6257
@@ -67,8 +62,7 @@ Now, plot the signal integrity map using a threshold to highlight areas with str
6762
6863.. code-block :: python
6964
70- # Plot the signal integrity map with a signal threshold
71- fig, ax = ovrlpy.plot_signal_integrity(integrity, signal, signal_threshold = 4.0 )
65+ fig = ovrlpy.plot_signal_integrity(dataset, signal_threshold = 4 )
7266
7367
7468 5. Detect and Visualize Overlaps (Doublets)
@@ -79,39 +73,29 @@ Identify overlapping signals (doublets) in the tissue and visualize them.
7973.. code-block :: python
8074
8175 # Detect doublet events (overlapping signals) in the dataset
82- doublet_df = ovrlpy.detect_doublets(
83- integrity,
84- signal,
85- signal_cutoff = 4 , # Threshold for signal strength
86- integrity_sigma = 1 # Controls the coherence of the signals
76+ doublets = dataset.detect_doublets(
77+ min_signal = 4 , # threshold for signal strength
78+ integrity_sigma = 1 , # controls the coherence of the signals
8779 )
8880
89- # Display the detected doublets
90- doublet_df.head()
81+ doublets.head()
9182
9283 6. 3D Visualization of a Doublet Event
9384______________________________________
9485
95- Visualize a specific overlap event (doublet) in 3D to see how it looks in the tissue.
86+ Visualize a specific overlap event (doublet) to see how it looks in the tissue.
9687
9788.. code-block :: python
9889
99- # Parameters for 3D visualization
90+ # Parameters for the visualization
10091 window_size = 60 # Size of the visualization window around the doublet
10192 doublet_to_show = 0 # Index of the doublet to visualize
10293
103- # Get the coordinates of the doublet event
104- x, y = doublet_df.loc[doublet_to_show, [ " x" , " y" ]]
94+ # Coordinates of the doublet event
95+ x, y = doublets[ " x" , " y" ].row(doublet_to_show)
10596
10697 # Plot the doublet event with 3D visualization
107- _ = ovrlpy.plot_region_of_interest(
108- x, y,
109- coordinate_df,
110- visualizer,
111- signal_integrity,
112- signal_strength,
113- window_size = window_size,
114- )
98+ fig = ovrlpy.plot_region_of_interest(dataset, x, y, window_size = window_size)
11599
116- This visualization shows a 3D representation of the spatial overlap event, giving more
117- insight into the structure and coherence of the signals.
100+ This visualization shows a top/bottom/side representation of the spatial overlap event,
101+ giving more insight into the structure and coherence of the signals.
0 commit comments