直接读取表达矩阵和metadata信息创建seurat单细胞对象

library(CellChat)
library(Seurat)
library(dplyr)
library(patchwork)
library(ggplot2)
library(ggalluvial)
library(svglite)
library(Seurat)
library(openxlsx)
library(harmony)
library(DoubletFinder)

library(tibble)
library(ggpubr)
library(data.table)
library(readr)
library(org.Mm.eg.db)
library(clusterProfiler)

getwd()
load("G:/silicosis/geo/GSE130148_Single cell RNA sequencing analysis of fresh resected human lung tissue/GSE130148_raw_counts.RData/GSE130148_raw_counts.RData")

raw_counts[1:4,1:4]
celldata=read.table(file = "G:/silicosis/geo/GSE130148_Single cell RNA sequencing analysis of fresh resected human lung tissue/GSE130148_barcodes_cell_types.txt/GSE130148_barcodes_cell_types.txt",
                    sep="\t")
head(celldata)
colnames(celldata)=celldata[1,]
cellmetadata=celldata[-1,]
head(cellmetadata)
rownames(cellmetadata)=cellmetadata[,1]
head(cellmetadata)

getwd()
asthma=CreateSeuratObject(counts = raw_counts,project = "asthma") #16327 features across 10360 samples


asthma[["percent.mt"]] <- PercentageFeatureSet(asthma, pattern = "^mt-")
VlnPlot(asthma, features = c("nFeature_RNA", "nCount_RNA","percent.mt"), ncol = 3)

load_number <- dim(asthma)
asthma = asthma %>% NormalizeData(normalization.method = "LogNormalize", scale.factor = 10000) %>%
  FindVariableFeatures(selection.method = "vst", nfeatures = 2000) %>%
  ScaleData() %>%
  RunPCA() %>%
  RunUMAP(dims = 1:30)
```

```
###[email protected]=cellmetadata #不可以直接这样添加metada
 
asthma=AddMetaData(asthma,metadata = cellmetadata)
head(cellmetadata)
boxplot(as.numeric(cellmetadata$percent.mito))

Idents(asthma)=asthma$celltype
DimPlot(asthma,label = TRUE)
save(asthma,file = "asthma.rds")

```

你可能感兴趣的:(笔记,r语言,seurat,addmodule,r)