DOI: 10.5281/zenodo.14571626
title: The spatio-temporal program of liver zonal regeneration - Code for paper

description: Analysis code for the paper "The spatiotemporal program of zonal liver regeneration following acute injury" (DOI https://doi.org/10.1016/j.stem.2022.04.008)

 

IMPORTANT:



Data required to run the code are in several locations:


1.       Large datasets were previously deposited in Zenodo and the link to the data sets is commented in the code when needed:

·        https://zenodo.org/records/10901217 - for raw Visium folders

·        https://zenodo.org/records/6035873 - for filtered and raw single cell, bulk and spatial transcriptomics. Single cell raw files DO NOT contain other previously published datasets used in our analyses. Please check the ‘Methods’ section in the paper for more details.  

2.       In the ‘data’ subdirectory and the path in the code is defined as “/data/SAMPLE_DATASET”. Make sure to update the link to the complete data directory path.



The MATLAB scripts often call auxiliary functions also uploaded in a directory called “helper_functions”. Please make sure the line addpath('PATH\TO\helper_functions') is at the beginning of each script (please make sure the full path is updated).

The paths to save files in the scripts were not changed from original code to avoid overriding and to allow future reference. Please update paths. 

The Seurat package used to generate the code was Seurat 4. Working with Seurat 5 would require adjustments to the code. As a general note, here we focus on data analysis and inference rather than on pre-processing. Hence, we have uploaded the filtered and preprocessed files. An example of processing a raw 10x 3’ scRNAseq run (with HTO) which we have used to each single cell run we included in our analysis, as well as the code used for integration of all scRNA runs are included. The raw data files are in Zenodo. 


 

 Directories’ content:

data

containing additional data structure to run the codes, such as manual annotations of Visium spots and count matrices for an easier compatibility with the code, data structure of scRNA in MATLAB subset per cell type (hepatocytes, HSC and endothelial cells) for the analysis of zonation reconstruction in these cell types, and precomputed tables and external datasets (from Bahar Halpern et al., 2018; Dobie et al., 2019) to compare the zonated ‘landmark’ genes from other datasets.

Helper_fucntions  

Functions used in MATLAB scripts which are used repeatedly, such as importing Visium data to MATLAB, extracting the spatial information, performing differential expression, extracting marker genes as well as some visualization functions.

 

10x_scRNA

Analysis of 10x scRNA seq 3’ with multiplexing using hashtag oligos (HTOs). Files are:

example_code_for_bg_and_doublet_removal.R – code used to preprocess our 10x individual runs. Includes loading the 10x output, remove ambiguous cells or doublets according to HTO, remove background by thresholding.

integrate_heps_and_NPCs.R – code used to integrate runs from all time points to a single integrated Seurat object, an in turn to more accurately annotate cell types and remove doublets.             

plot_umap_all_cells.R – code to plot the UMAPs with the color coding as in the paper.

 

Visium_spatial_tx

Analysis of Visium spatial transcriptomics. File is:

pipeline_analyze_visium_physical_dist.m – 

·        Importing Visium data using the helper function: 

helper_functions\import_visium_data.m 

The scripts import the data of the visium for each time point, including the coordinates and the gene expression matrix of each spot. The script also uses manually annotation files to get the fibrotic identity of the spots as well as spots to remove. 

Skeletonizing the fibrotic spots into “central veins” and correcting distances to cv in um units: helper_functions\normalize_dist_and_skeltonize.m

The script calculates the physical distance of the spots. In addition, the visium grid is converted into rectangular (from hexagonal), and the fibrotic spots in the image are skeletonized while continuity is preserved. Minimal distance of each spot to the CV skeleton is then calculated.

·        Spots are binned into 3 zones based on the resulting dist2cv, with spots exceeding 350um from nearest CV removed from further analysis.

·        Zonation profiles were calculated for all genes over the 3 zones using the function helper_functions\get_zonation_profile2.m

·        Based on a signature matrix which was calculated for each cell type in each timepoint (data\sig.mat) cell type specific genes were extracted, for either hepatocytes, HSC, or endo. those cell-type specific genes were renormalized to their sum in each spot, and the zonation profiles of the cell-types specific genes were calculated. The function that extracts the marker/signature genes is helper_functions\extract_marker_genes2.m and the zonation profile is calculated by helper_functions\get_zonation_profile2.m

sc_zonation_reconstruction

inferring the spatial location (zone) of each of the single hepatocytes (analyse_hep.m), HSC (analyze_spatio_temporal_hsc_2312.m) and endo (analyze_spatio_temporal_endo_2312.m) using ‘landmark genes’ in each of the time points. (see ‘Methods’ section). For hepatocytes, also interface hepatocytes analysis is included in the script.