Your data should contain an x and y column , which is the centroid for each cell/item and a column specifying which region each cell/item is from e.g. sample_id, roi, slide_number. In addition it needs to contain a column that will be used to color centroid plots e.g. annotations, cell types, cluster designations.
use the set_region_data
method of the MDVProject. For example to set regions for the cell's datasource
p.set_region_data("cells", "/path/to/file",
region_field="sample_id",
default_color="annotations",
position_fields=["x", "y"],
scale_unit="mm",
scale=0.001)
The first argument is the name of the datasource and the second is a path to a tab delimited table or a dictionary describing the regions e.g.
sample_id | width | height |
---|---|---|
sample_1_roi_1 | 2000 | 2000 |
sample_1_roi_2 | 1250 | 1500 |
The first column should contain the name of the region (can be any header). The other columns are:-
Alternatively instead of a path to a file, a dictionary of region name to data can be used e.g.
{
"sample_1":{
"width":2000,
"height":2000
}
}
The other arguments are:-
Use `add_region_images' to add background images:-
p.add_region_images("cells", "examples/data/spatial/images.tsv")
The second argument should be a path to a tab delimited table or a dictionary describing the images
sample_id | path | name |
---|---|---|
sample_1_roi_1 | /path/to/images/sample_1_roi_1/cellmask.png | cellmask |
sample_1_roi_1 | /path/to/images/sample_1_roi_1/he_stain.png | HE |
sample_2_roi_1 | /path/to/images/sample_2_roi_1/cellmask.png | cellmask |
The table should contain the region name (first column) then a path column which should contain either a url to an image or a local path to an image and name for the image. Multiple images for the same region are allowed but they must have different names.
x_offset, y_offset, width and height columns can also be included if the background image is larger or offset from the region. If these values are not present, they will be the same as those of the region. The user is also able to try and align the image with centroids.
If a local file path is given in 'path', the image will be copied to the project and the correct url for displaying it will be constructed.
Use add_viv_viewer
of the `MDVProject'
p.add_viv_viewer("cells",
[
{"name": "DNA1", "color": "#23133"},
{"name": "collagen", "color": [223, 21, 123]}
]
)
The first argument is the datasource name, and the second the default channels. Contrast limits can be added , but usually these are calculated based on the image. Colors can be either hex or an RGB list. They can also be omitted and default colors will be assigned. These are only the initial values and channels can be added/removed and edited by the user. The user is also able to set new defaults
To add ome-tiffs use add_viv_images
. The format is the same as for the normal regions images i.e. a path to a file or a dictionary and again can either be a url or a path to a local images
p.add_viv_images("cells", {
"COVID_OP_SAMPLE_ID_6_ROI_1": {
"path": "/path/to/COVID_OP_SAMPLE_ID_6_ROI_1.ome-tiff"
},
"COVID_OP_SAMPLE_ID_6_ROI_2": {
"path": "https://mysite/images/C_ID_6_2.ome.tiff"
}
})
First add a datasource, that describes each cell/cell interaction for each ROI or condition (group of ROIs). The datasource should contain the following:-
Cell Type 1 | Cell Type 2 | cell 1 number | cell 2 number | sample_id | gr20 | contacts |
---|---|---|---|---|---|---|
B cell | T cell | 143 | 36 | sample_6_roi_1 | 2.3 | 100 |
B cell | CD24 | 143 | 24 | sample_6_roi_1 | 0.8 | 27 |
Then use the set_interactions methods to specify that the dataset contains interaction data and to link it to parent dataset e.g. cells
p.set_interactions("my_interactions","cells",
pivot_column="sample_id",
parent_column="annotation",
is_single_region=True,
interaction_columns=["Cell Type 1","Cell Type 2"],
default_parameter="Cross PCF gr20",
node_size="cell 1 number",
add_view=True)