-
Notifications
You must be signed in to change notification settings - Fork 0
/
part2_RNAvelocity_Seurat.Rmd
58 lines (40 loc) · 1.54 KB
/
part2_RNAvelocity_Seurat.Rmd
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
title: "RNA Velocity analysis using velocyto, Seurat, and scVelo (Part 2: Seurat data)""
subtitle: "Extract data from Seurat to merge with Loom file for scVelo RNA velocity"
author: "Katherine Beigel ([email protected])"
---
# Saving Seurat object as h5ad
This script does not include any Seurat processing steps. The "WT_Seurat.rds" input file is expected to be a fully processed Seurat object (with UMAP, clustering, etc.).
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
# main
library(tidyverse)
library(Seurat)
library(SeuratDisk)
library(viridis)
library(ggplot2)
library(scales)
library(mgsub)
library(cowplot)
```
## Set the directory for where to read/write data files
```{r Directories}
datadir <- "/dir/where/to/load/SeuratObj/from/"
outdir <- "/dir/where/to/write/outputfiles/to/"
```
## Load the RDS file
```{r Load rds Seurat file}
seu <- readRDS(file = paste0(datadir, "WT_Seurat.rds"))
# Optional: if you need to subset the object to only look at some cells
# Idents(object = seu) <- "orig.ident"
# seu <- subset(seu, idents = "WT_sub")
# Check to see how the UMAP plot looks
DimPlot(seu, group.by = "cell_type", label = TRUE)
```
## Save the Seurat object as a h5Seurat, convert to .h5ad
Vignette: https://mojaveazure.github.io/seurat-disk/articles/convert-anndata.html
```{r Convert Seurat to .h5ad, eval = FALSE}
# Uses pkg SeuratDisk
SaveH5Seurat(seu, filename = paste0(outdir, "WT_seurat.h5Seurat"))
Convert(paste0(outdir, "WT_seurat.h5Seurat"), dest = "h5ad") # this file will be used in Part 3: scVelo RNA velocity
```