Processing large real datasets¶
This document describes how to run large real datasets with FICTURE. Most of the contents here are similar to the small run document, but we provide more details on how to submit jobs to a SLURM cluster, using prepared scripts in the examples/script/
directory.
In this example, we will use a small sub-region of Vizgen MERSCOPE mouse liver data as an example. (The same region we showed in supplementary figure X)
This document assume you have intalled FICTURE. See installing FICTURE for more details.
Input¶
Transcripts
One file contains the molecular or pixel level information, the required columns are X
, Y
, gene
, and Count
. (There could be other columns in the file which would be ignored.)
The coordinates (X, Y)
can be float or integer numbers in arbitrary units, but if it is not in the unit of \(\mu m\) we would need to specify the translation ratio later.
The file has to be sorted by one of the coordinates. (Usually it is the longer axis, but it does not matter if the tissue area is not super asymmetric.)
Count
(could be any other name) is the number of transcripts for the specified gene
observed at the coordinate. For imaging based technologies where each molecule has its unique coordinates, Count
could be always 1.
Bounding box of spatial coordinates
We also prefer to keep a file listing the min and max of the coordinates (this is primarily for visualizing very big tissue region where we do not read all data at once but would want to know the image dimension). The unit of the coordinates is micrometer.
Process¶
Specify the base directory that contains the input data
Data specific setup:
mu_scale
is the ratio between \(\mu m\) and the unit used in the transcript coordinates. For example, if the coordinates are sotred in nm
this number should be 1000
.
key
is the column name in the transcripts file corresponding to the gene counts (Count
in our example). MJ
specify which axis the transcript file is sorted by.
Example bash scripts are in examples/script/
, you will need to modify them to work on your system.
Create pixel minibatches (${path}/batched.matrix.tsv.gz
)
Set up parameters for initializing the model.
Parameters for pixel level decoding
Perform model fitting and pixel-level decoding
Output¶
In the above example the analysis outputs are stored in
There is an html file reporting the color code and top genes of the inferred factors
Pixel level visualizating
Pixel level output is
We store the top 3 factors and their corresponding posterior probabilities for each pixel in tab delimted text files.
As a temporary hack for accessing specific regions in large dataset faster, we divided the data along one axis (X or Y), sorted within each block by the other axis.
The first 3 lines of the file, starting with ##
, are metadata, the 4th line, starting with #
, contains columns names.
To use the file as plain text, you can ignore this complication and read the file from the 4th line.
The first few lines of the file are as follows:
The 4th line contains the column names. From the 5th line on, each line contains the information for one pixel with coordinates (X, Y)
, the top 3 factors indicated by K1, K2, K3
and their corresponding posterior probabilities P1, P2, P3
. Factors are 0-indexed.
The 1st line indicates that the data is from a model with 12 factors (K=12
) and we store the top 3 factors for each pixel (TOPK=3
).
The 2nd line indicates that the data is separated into blocks by the X axis (BLOCK_AXIS=X
) with block size 2000\(\mu m\) (BLOCK_SIZE=2000
), then within each block the data is sorted by the Y axis (INDEX_AXIS=Y
).
The block IDs (first column in the file) are integer multiples of the block size (in \(\mu m\)), i.e. the 1st block, with \(X \in [0, 2000)\) have block ID 0, the 2nd block, with \(X \in [2000, 4000)\) have block ID 2000, etc.
The 3rd line describes the translation between the stored cooredinates and the physical coordinates in \(\mu m\).
Take (X, Y)
as a pixel coordinates read from the file, the physical coordinates in \(\mu m\) is (X / SCALE + OFFSET_X, Y / SCALE + OFFSET_Y)
.
In this above example, the raw data from Vizgen MERSCOPE mouse liver data contains negative coordinates, but for convineince we shifted all coordinates to positive. SIZE_X
and SIZE_Y
record the size of the raw data in \(\mu m\).