-
Notifications
You must be signed in to change notification settings - Fork 0
/
scRNA_pipeline_v1.Rmd
98 lines (71 loc) · 2.9 KB
/
scRNA_pipeline_v1.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
---
title: "scRNA_pipeline_v1"
author: Stephanie The
date: 6/13/19
output: html_document
---
Load required packages
``` {r setup, include = FALSE}
library(Seurat)
library(dplyr)
library(magrittr)
library(pheatmap)
library(RColorBrewer)
library(scales)
library(data.table)
# Load umap
Sys.setenv(PATH= paste("C:/Users/Stephanie/Anaconda3/envs/r-reticulate/Library/bin",Sys.getenv()["PATH"],sep=";"))
Sys.setenv(RETICULATE_PYTHON = "C:/Users/Stephanie/Anaconda3/envs/r-reticulate/python.exe")
library(reticulate)
use_condaenv("r-reticulate")
py_config()
import("umap")
```
Load cell cycle genes (mouse or human choices only)
``` {r}
species <- readline(prompt = "What species are you working with?\n")
if (species == 'human') {
s_genes <- cc.genes$s.genes
g2m_genes <- cc.genes$g2m.genes
}
else { # mouse
readRDS(("~/Rao's Lab/Single Cell/single_cell/mouse_cell_cycle_genes/mouse_cell_cycle_genes.rds")
s_genes <- mouse_cell_cycle_genes$s.genes
g2m_genes <- mouse_cell_cycle_genes$g2m.genes
}
```
Load data and create Seurat objects (first time)
```{r}
n_files <- readline("How many files do you have? ")
files <- c()
files <- sapply(1:n_files, function(i) files <- c(files, choose.dir(caption = paste("Directory", i,
sep = " "))))
# Save directories in case you want to go back to this step
fwrite(as.list(files), file = "directories.txt")
# Create Seurat objects
# names must in order of directories/data
object_names <- unlist(strsplit(readline(prompt = "Object names (separate by ', ')"),split = ', '))
project_names <- unlist(strsplit(readline(prompt = "Project names (separate by ', ')"),split = ', '))
object_list <- list()
object_list <- sapply(1:n_files, function(i) object_list <- append(object_list, object_names[i] = CreateSeuratObject(Read10X(files[i]), project = project_names[i], min.cells = 3, min.features = 100)))
```
Load data and create Seurat objects (after first time)
``` {r}
files <- c(fread(file.choose(), sep = ',', header = F, stringsAsFactors = F))
files <- unname(unlist(files))
```
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars}
summary(cars)
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.