Last active
February 13, 2020 16:43
-
-
Save dosorio/573a9d1c91d34749e857ca2d2f4e6838 to your computer and use it in GitHub Desktop.
SC-2-13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Loading Seurat | |
library(Seurat) | |
# Moving to downloads | |
setwd("../Downloads/") | |
# Getting the input files from 10X Genomics | |
inputFile <- "http://cf.10xgenomics.com/samples/cell-exp/3.0.0/pbmc_1k_protein_v3/pbmc_1k_protein_v3_filtered_feature_bc_matrix.tar.gz" | |
download.file(inputFile, "PBMC.tar.gz") | |
untar("PBMC.tar.gz") | |
#Input Folder | |
inputFolder <- "filtered_feature_bc_matrix/" | |
# Loading Seurat | |
library(Seurat) | |
# Reading the dataset | |
PBMC <- Read10X(inputFolder) | |
PBMC <- PBMC[[1]] | |
# QC | |
mtReads <- PBMC[grepl("MT-", rownames(PBMC)),] | |
mtRate <- (apply(mtReads,2,sum)/apply(PBMC,2,sum)) | |
plot(mtRate, pch=16) | |
abline(h = 0.1, col = "red", lty = 2) | |
# Filtering | |
PBMC <- PBMC[apply(PBMC,1,sum) != 0,] | |
PBMC <- PBMC[,mtRate < 0.1] | |
# Creating a Seurat Object | |
PBMC <- CreateSeuratObject(PBMC) | |
# Normalizing the dataset | |
PBMC <- NormalizeData(PBMC) | |
PBMC <- ScaleData(PBMC) | |
# Accessing to the raw data | |
PBMC@assays$RNA@counts | |
# Accessing to the normalized data | |
PBMC@assays$RNA@data | |
# Dimentionality Reduction | |
PBMC <- FindVariableFeatures(PBMC) | |
PBMC <- RunPCA(PBMC) | |
PCAPlot(PBMC) | |
PBMC <- RunTSNE(PBMC, perplexity = 100) | |
TSNEPlot(PBMC) | |
PBMC <- RunUMAP(PBMC, dims = 1:50) | |
UMAPPlot(PBMC) | |
# Marker Genes | |
FeaturePlot(PBMC, features = c("MS4A1", "GNLY", "CD3E", "CD14", "FCER1A", "FCGR3A", "LYZ", "PPBP", "CD8A")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment