-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExplore_Data.R
28 lines (23 loc) · 1.1 KB
/
Explore_Data.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
library(Seurat)
setwd("SETYOURDIRECTORY_TO_DATA")
# Data reload
rawdata <-Read10X(data.dir = getwd(), gene.column = 1)
rawdata[1:5,1:5]
metadata <-read.table(file = "metadata.tsv.gz", header = T, sep = "\t", row.names = 1)
head(metadata) #celltype is cluster number
# Create Seurat object, including batch-corrected PCA coordinates (i.e. harmony) and UMAP.
SO <- CreateSeuratObject(counts = rawdata, project = "Cardiac Gastruloids", meta.data = metadata)
SO <- NormalizeData(object = SO, scale.factor = 10000)
SO[["harmony"]] <- CreateDimReducObject(embeddings = as.matrix(metadata[,paste0("harmony_",1:30)]),key = "harmony_",assay = "RNA")
SO[["umap"]] <- CreateDimReducObject(embeddings = as.matrix(metadata[,c("UMAP_1","UMAP_2")]),key = "UMAP_",assay = "RNA")
[email protected][,grep("harmony",colnames([email protected]))] <- NULL
[email protected][,grep("umap",colnames([email protected]))] <- NULL
# Visualize timepoints
Idents(SO) <- SO$stage
DimPlot(SO)
# Visualize cell types
Idents(SO) <- SO$celltype
DimPlot(SO, label = T)+NoLegend()
# Plot gene expression
gene_list <- c("Myl7","Sox2","Pou5f1","T")
FeaturePlot(SO, gene_list)