my R
rm(list = ls())
gc()
library(Seurat)
library(stringr)
library(scales)
library(magrittr)
library(RColorBrewer)
library(ggplot2)
library(UCell)
myhead = function(x,DT=FALSE){
print(paste('Data dimension: ',dim(x)[1],dim(x)[2]))
if(dim(x)[2]>5){
print(x[1:5,1:5])}
else(print(head(x)))
if(DT){
DT::datatable(x,filter='top')}
}
mycolors = c("#1a476f","#90353b","#55752f","#e37e00","#6e8e84",
"#c10534","#938dd2","#cac27e","#a0522d","#7b92a8",
"#2d6d66","#9c8847","#bfa19c","#ffd200","#d9e6eb",
"#4DBBD5B2", "#00A087B2", "#3C5488B2",
"#F39B7FB2", "#8491B4B2","#91D1C2B2","#DC0000B2",
"#7E6148B2","#E64B35B2",'#698EC3')
show_col(mycolors)
options(stringsAsFactors = F)
options(as.is = T)
setwd('/media/yuansh/14THHD/BscModel-V4/supplementary materials/DEGs')
df = read.csv('GSE131907-Cancer_absolute_scale_wilcoxon.csv',row.names = 1)
df = df[which( (abs(df$logfoldchanges) > 2) & (df$pvals_adj < 0.05) ),]
单细胞基因过滤
### ---------------
### Create: Yuan.Sh, MD (ORCID: 0000-0002-6028-0185)
### Date: Aug. 30, 2022
### Email: yuansh3354@163.com
### Blog: https://blog.csdn.net/qq_40966210
### Github: https://github.com/yuansh3354/
### Fujian Medical University. No. 1 Xue Yuan Road,University Town, 350122 FuZhou Fujian, China
### National Center for Nanoscience and Technology (NCNST). No.11 ZhongGuanCun BeiYiTiao, 100190 Beijing, China
### ---------------
############# Step.00 #############
Pseudogenes = read.csv('Result/Pseudogenes.csv')
eliminate_genes = function(sce.obj,Pseudogenes){
sce.obj[["percent.mt"]] = PercentageFeatureSet(sce.obj, pattern = "^MT-")
if(sum(grepl('^MT-',rownames(sce.obj))) > 0){
sce.obj = sce.obj[!grepl('^MT-',rownames(sce.obj)),] # 过滤线粒体
}
ids = intersect(Pseudogenes[,1],rownames(sce.obj)) %>% setdiff(rownames(sce.obj),.)
if(length(ids)>0){sce.obj = sce.obj[ids,]}
if(sum(grepl('\\.[0-9]+$&#