Skip to content

Latest commit

 

History

History
executable file
·
124 lines (96 loc) · 3.54 KB

4.Mouse_liver.md

File metadata and controls

executable file
·
124 lines (96 loc) · 3.54 KB

Demonstration of SpaTrio on mouse liver datasets

yph 2023-03-07

Library required R packages

library(Seurat)
## Attaching SeuratObject
library(SpaTrio)
library(ggsci)
library(ggplot2)
library(readr)

Load datasets

We collected mouse liver data (10x Visium with highly multiplexed protein) (https://www.livercellatlas.org/index.php), and based on this, we built a set of single-cell multi-omics data and a set of spatial transcriptome data.

multi_object <- readRDS("data/Mouse_liver/multi_object.rds")
spatial_object <- readRDS("data/Mouse_liver/spatial_object.rds")
dim(multi_object)
## [1] 31053  1398
dim(spatial_object)
## [1]  93 261
color<-c("#425eaf","#bed4eb","#daa247","#a61414")
Idents(multi_object)<-multi_object$zonationGroup
sdplot(multi_object,pt.size.factor=2.2,image.alpha = 0,stroke = NA,shape=21)+scale_fill_manual(values = color)
## Scale for fill is already present.
## Adding another scale for fill, which will replace the existing scale.

Idents(spatial_object)<-spatial_object$zonationGroup
sdplot(spatial_object,pt.size.factor=5,image.alpha = 0,stroke = NA,shape=21)+scale_fill_manual(values = color)
## Scale for fill is already present.
## Adding another scale for fill, which will replace the existing scale.

Run SpaTrio

We enter the following data into SpaTrio, which will build spatial maps of single cells

  • Gene expression count matrix of cells and spots (multi_rna.csv & spatial_rna.csv)
  • Cluster/Cell-type information of cells and spots (multi_meta.csv & spatial_meta.csv)
  • Low-dimensional representation of protein assay (emb.csv)
  • Spatial position coordinates of spots (pos.csv)
spatrio(spatrio_path="/home/yph/SpaTrio-main",
        py_path="/home/yph/anaconda3/envs/spatrio/bin/python",
        input_path="data/Mouse_liver",
        output_path="data/Mouse_liver",
        top_num =5)
## [1] "Using the Python interpreter with a path of /home/yph/anaconda3/envs/spatrio/bin/python"

Results of SpaTrio

output <- read_csv("data/Mouse_liver/output.csv")
## New names:
## Rows: 1305 Columns: 10
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (4): spot, cell, spot_type, cell_type dbl (6): ...1, value, x, y, Cell_xcoord,
## Cell_ycoord
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
pred<-subset(multi_object,cell=output$cell)
coordinate = output[,c("Cell_xcoord","Cell_ycoord")]
coordinate<-as.data.frame(coordinate)
colnames(coordinate)<-c("x","y")
rownames(coordinate)<-output$cell
pred@images[["slice1"]]=NULL
pred@images$image =  new(
Class = 'SlideSeq',
assay = "RNA",
key = "image_",
coordinates = coordinate)
output<-as.data.frame(output)
rownames(output)<-output$cell
pred<-AddMetaData(pred, output[,2:10])
sdplot(pred,pt.size.factor=6,image.alpha = 0,stroke = NA,shape=21)+scale_fill_manual(values = color)+NoLegend()
## Scale for fill is already present.
## Adding another scale for fill, which will replace the existing scale.