To prepare for the experiments, 1) download the directory FIST_data from this link; and 2) download all the script files in this GitHub repo to the FIST_data directory.
The folders (10x_data, Replicates_data, FIST_utils, FIST_res, SpatialNN_res, REMAP_res, GWNMF_res, ZIFA_res) in FIST_data are described below:
10x_data: 1) The spatial gene expression tensors from 10 tissue sections (HBA1, HBA2, HH, HLN, MKC, MBC, MB1P, MB2P, MB1A, MB2A); 2) The Homo sapiens and Mus musculus protein-protein interactions (PPI) networks obtained from BioGRID; 3) The gene ids for each of the 10 tissue sections.Replicates_data: 1) The spatial gene expression tensors from 3 replicates of mouse tissue (olfactory bulb); 2) The Mus musculus protein-protein interactions (PPI) networks obtained from BioGRID; 3) The gene ids for each of the 3 replicates.
(Note: We also provide the R script Convert2Tensor_Visium.R and Convert2Tensor_ST.R with step-by-step instructions on how to convert the raw spatial transcriptomic datasets from 10x Genomics and Ståhl et al. (2016) to tensors.)
FIST_Tutorial: The folder used for the tutorial.FIST_Tutorial_Output: The output folder of the tutorial.
FIST_utils: The utility files required for running FIST, which includes 1) the main functionFIST.m; 2) the supporting functionstrain_valid_FIST.mandtest_FIST.mfor the gene-wise cross-validation on the 10x Genomics data; 3) all the files in the MATLAB Tensor Toolbox package.
The cross-validation results for FIST are stored in FIST_res. The cross-validation results for the baseline methods REMAP, GWNMF, ZIFA and Sptial-NN are stored in REMAP_res, GWNMF_res, ZIFA_res and SpatialNN_res. (Note: Spatial-NN is a baseline method created by ourselves, the implementation is provided in this GitHub repo.)
You can downloaded any Visium data (Space Ranger v1.0.0) to from 10x genomics website. In this tutorial, we will use a human heart dataset as an example.
Under Visium Spatial for FFPE Demonstration (v1 Chemistry)/Visium Demonstration (v1 Chemistray) choose tab "Space Ranger v1.0.0". Click the "Human Heart" link, fill in the form and check the consent to access the data.
We only use filtered feature-barcode matrix data and spatial coordindates provided in the download file list. They can also be downloaded with following links filtered feature-barcode matrix data and spatial coordinates.
Then unzip the downloaded data and organize folders using the following structure under a home-folder for your experiment:
. FIST_Tutorial
├── V1_Human_Heart
│ ├── filtered_feature_bc_matrix
│ │ ├── barcodes.tsv.gz
│ │ ├── features.tsv.gz
│ │ └── matrix.mtx.gz
│ ├── spatial
│ │ ├── tissue_positions_list.csv
(more about filtered feature-barcode matrix data and spatial coordinates)
Under folder FIST_data, use the following command line to run the R script for converting the data
Rscript Convert2Tensor_Visium.R --input FIST_Tutorial --output FIST_Tutorial_Output
After running the script, a matlab file V1_Human_Heart.mat and a gene list file V1_Human_Heart.csv will be generated in the folder FIST_Tutorial_Output.
Open the script run_FIST_Tutorial.m in matlab. Replace yourpath in the line "work_path = 'yourpath/FIST_data';" with the FIST installation directory. Then run the script. The imputed tensor will be saved in V1_Human_Heart_output.mat in the folder FIST_Tutorial_Output
This tutorial only works for human and mouse visium data. To work with other species, you need to dowload PPI networks and prepare them in .mat format under the folder FIST_Tutorial_Output and change the code in data_prep_10x.m to read in the PPI.
Step 1: generate the tensor data from the raw data (skip this step if directly work on the processed tensor data in the preparation step)
The tensor data are already prepared by Convert2Tensor_Visium.R and Convert2Tensor_ST.R in the folder 10x_data.
Next, open MATLAB and load the .mat file provided in the preparation under 10x_data folder or outputted by the Rscript command in the previous step, cd to the FIST_utils folder, and run V = sptensor([V.x_aligned_coords V.y_aligned_coords V.variable], V.value, [double(X) double(Y) double(Z)]); to generate the data tensor.
- Spot-wise cross-validation on the 10x Genomics data: Run
FIST_crossvalidation_10xfiber.mandSpatialNN_crossvalidation_10xfiber.mto test FIST and the baseline Spatial-NN respectively. - Gene-wise cross-validation on the 10x Genomics data: Run
FIST_crossvalidation_10xslice.mandSpatialNN_crossvalidation_10xslice.mto test FIST and the baseline Spatial-NN respectively. - Spot-wise cross-validation on the mouse tissue replicates data: Run
FIST_crossvalidation_replicates_fiber.mandSpatialNN_crossvalidation_replicates_fiber.mto test FIST and the baseline Spatial-NN respectively.
Run plot_Figure2.m, plot_Figure3.m, plot_Figure4.m, plot_Figure8.m, plot_Figure9.m, plot_FigureS345.m and generate_S1_Table.m to display the key results in the paper.