library(Seurat)
library(dplyr)
library(cowplot)
library(ggplot2)
library(harmony)
library(patchwork)
library(openxlsx)
#library('harmony')
rm(list=ls())file = "D:/ARDS_scripts_1012/ARDS/Step2_harmony_f200_R3/0823/wxj_4_Platelet_"## 改成想存放文件的路径dir.create(file)
setwd(file)
getwd()#从sepsis_cluster_merge.rds获得选定的细胞群==load("D:/ARDS_scripts_1012/ARDS/Step2_harmony_f200_R3/0805/cluster_merge/sepsis_cluster_merge.rds")##   改路径
as.matrix(table(Idents(All.merge), All.merge$stim))subset_data.count = All.merge@assays$RNA@counts[, which(All.merge$cell.type == "Platelet")]##15499  115
dim(subset_data.count)subset_data = CreateSeuratObject(counts = subset_data.count, project = "Platelet")
subset_data[["percent.mt"]] <- PercentageFeatureSet(subset_data, pattern = "^mt-")
nFeature_RNA=200
VlnPlot(subset_data, features = c("nFeature_RNA", "nCount_RNA", "percent.mt"), ncol = 3)
dim(subset_data)subset_data = subset_data %>%Seurat::NormalizeData(verbose = FALSE) %>%  FindVariableFeatures(selection.method = "vst", nfeatures = 2000) %>%ScaleData(verbose = FALSE) %>%RunPCA(npcs = 50, verbose = FALSE)
ElbowPlot(subset_data, ndims = 50)
VlnPlot(subset_data, features = c("nFeature_RNA", "nCount_RNA", "percent.mt"), ncol = 3)## 466  510
subset_data@meta.data$stim <- c(rep("Exp", length(grep("1$",colnames(subset_data)))),rep("Con", length(grep("2$",colnames(subset_data)))))
table(subset_data$stim)##########################run harmony
#BiocManager::install('harmony')
library('harmony')
subset_data <- subset_data %>% RunHarmony("stim", plot_convergence = TRUE)
harmony_embeddings <- Embeddings(subset_data, 'harmony')
#######################cluster
dims = 1:30
subset_data <- subset_data %>% RunUMAP(reduction = "harmony", dims = dims) %>% RunTSNE(reduction = "harmony", dims = dims) %>% FindNeighbors(reduction = "harmony", dims = dims)
#save(subset_data, file="sepsis_Platelet.rds")
load("sepsis_Platelet.rds")load("D:\\Win10 System\\Documents\\WeChat Files\\wxid_f27yna03e0v622\\FileStorage\\File\\2023-01\\.RData")DotPlot(subset_data,features = "Fyn",split.by = "stim")
FeaturePlot(subset_data,features = "Fyn",split.by = "stim")
DimPlot(subset_data,features = "Fyn",split.by = "stim")DotPlot(subset_data,features = c("Fyn","Xrk8",'Lyn',  'Lck' ,'Syk', 'Txk' ,  'Plscr1', 'Ano6' ),split.by = "stim")DotPlot(subset_data,features = c("Fyn","Xrk8",'Lyn',  'Lck' ,'Syk', 'Txk' ,  'Plscr1', 'Ano6' ),group.by = "stim")+ggtitle("platelet")DotPlot(All.merge,features = c("Fyn","Xrk8",'Lyn',  'Lck' ,'Syk', 'Txk' , 'Plscr1', 'Ano6' ),group.by = "stim")+ggtitle("Endothelial cells")table(subset_data$stim)
print("platelet")
table(subset_endo$stim)DotPlot(subset_endo,features = c("Fyn", 'Plscr1', 'Ano6' ),group.by = "stim")+ggtitle("Endothelial cells")############################2023-1-31
load("D:/ARDS_scripts_1012/ARDS/Step2_harmony_f200_R3/0805/cluster_merge/sepsis_cluster_merge.rds")##   改路径
as.matrix(table(Idents(All.merge), All.merge$stim))DotPlot(All.merge,features = c("Fyn"),group.by = "cell.type",split.by = "stim")+ggtitle("All cells")markers=c("Fyn",  "Plscr1","Ano6",  "Prkch",
"Lck", "Txk","Cd300a","Cd300lb","Cd300lf","Havcr2","Mfge8")#Kxr8, Rage 两个基因在单细胞里不存在
grep(pattern = "xr",rownames(All.merge),value = T)DotPlot(All.merge,features = markers,group.by = "cell.type",split.by = "stim")+RotatedAxis()+ggtitle("All cells")
# 把markers输出为pdf文件
getwd()
file = "D:/ARDS_scripts_1012/ARDS/Step2_harmony_f200_R3/0823/wxj_4_Platelet_"##   改成想存放文件的路径dir.create(file)
setwd(file)
getwd()for (eachgene in markers) {DotPlot(All.merge,features = eachgene,group.by = "cell.type",split.by = "stim")+ggtitle("All cells")ggplot2::ggsave(filename = paste0(eachgene,".pdf"),width = 7,height = 9)}###############################33不需要运行
r = 0.2
if (TRUE)
{load(paste(file, "sepsis_Platelet.rds", sep="/"))dir.create(paste(file,r,sep="/"))setwd(paste(file,r,sep="/"))subset_data <- FindClusters(subset_data, resolution = r)save(subset_data, file=paste0("sepsis_Platelet_r", r, ".rds"))subset_data <- ScaleData(subset_data, verbose = FALSE, features = rownames(subset_data))pdf("1_Platelet_cluster_TSNE.pdf")p = DimPlot(subset_data, reduction = "tsne", label = TRUE, pt.size = 1,label.size = 6)print(p)dev.off()pdf("1_Platelet_cluster_UMAP.pdf")p = DimPlot(subset_data, reduction = "umap", label = TRUE, pt.size = 1,label.size = 6)print(p)dev.off()stat = cbind(table(Idents(subset_data), subset_data$stim), All = rowSums(table(Idents(subset_data), subset_data$stim)))stat = rbind(stat, All = colSums(stat))stat<-as.data.frame(stat)statwrite.xlsx(stat, "2_Platelet_cluster_stat.xlsx", col.names=T, row.names=T)######################## find markermarkers <- FindAllMarkers(subset_data,  min.pct = 0.25, logfc.threshold = 0.25, only.pos=T)write.xlsx(markers,"3_Platelet_cluster_markers.xlsx", col.names=T,row.names=F)
}r = 0.2
load(paste(file, "sepsis_Platelet.rds", sep="/"))
dir.create(paste(file,r,sep="/"))
setwd(paste(file,r,sep="/"))
subset_data <- FindClusters(subset_data, resolution = r)
save(subset_data, file=paste0("sepsis_Platelet_r", r, ".rds"))
subset_data <- ScaleData(subset_data, verbose = FALSE, features = rownames(subset_data))
pdf("1_Platelet_cluster_TSNE.pdf")
p = DimPlot(subset_data, reduction = "tsne", label = TRUE, pt.size = 1,label.size = 6)
print(p)
dev.off()
pdf("1_Platelet_cluster_UMAP.pdf")
p = DimPlot(subset_data, reduction = "umap", label = TRUE, pt.size = 1,label.size = 6)
print(p)
dev.off()
stat = cbind(table(Idents(subset_data), subset_data$stim), All = rowSums(table(Idents(subset_data), subset_data$stim)))
stat = rbind(stat, All = colSums(stat))
write.xlsx(stat, "2_Platelet_cluster_stat.xlsx", col.names=T, row.names=T)
######################## find marker
markers <- FindAllMarkers(subset_data,  min.pct = 0.25, logfc.threshold = 0.25, only.pos=T)
write.xlsx(markers,"3_Platelet_cluster_markers.xlsx", col.names=T,row.names=F)

wxj platte相关推荐

  1. 决策树模型 朴素贝叶斯模型_有关决策树模型的概述

    决策树模型 朴素贝叶斯模型 Decision Trees are one of the highly interpretable models and can perform both classif ...

  2. wxj项目的开发一点记录

    <#-- 头部文件 --><#include "/wxj/common/header.ftl"> <script src="/resourc ...

  3. 无限极分类在html怎么用,wxj.html

    ul { list-style: none; display: list-item; min-height:50px; } .actions-inline { display: inline-bloc ...

  4. KMP的个人向总结(next数组 || DFA实现--JAVAC++魔改版)--by wxj

    之前学过KMP算法,但是当时学的时候就是比较模糊,对于它的认知也处在会用,会写的层次,但是对于它的内部的实现原理,仍是似懂非懂的状态,现在老师讲到字符串匹配算法的时候,我就重新学了一遍KMP,感觉之前 ...

  5. 支持向量机(SVM)

    SVM简介 SVM,Support Vector Machine,它是一种二分类模型,其基本模型定义为特征空间上的间隔最大的线性分类器,其学习策略便是间隔最大化,最终可转化为一个凸二次规划问题的求解. ...

  6. android侧滑布局,Android布局控件DrawerLayout实现完美侧滑效果

    drawerLayout其实是一个布局控件,跟LinearLayout等控件是一样的,但是drawerLayout带有滑动的功能.只要按照drawerLayout的规定布局方式写完布局,就能有侧滑的效 ...

  7. 第十次课:前台首页设计及显示商品信息

    一.前台首页设计 0.css样式 @charset "utf-8"; /*全局设置*/ *{  padding:0;  margin:0; } body {  font-size: ...

  8. 第十八课.支持向量机

    目录 线性可分支持向量机 模型公式 函数间隔与几何间隔 函数间隔 几何间隔 间隔关系 优化算法 支持向量 线性支持向量机 问题定义 折页损失 非线性支持向量机 问题定义 特征变换 核函数 多项式核函数 ...

  9. 246.三元图的应用与绘图实战

    三元图在微生物组研究中的应用 本节作者:吴一磊,中科院微生物所 版本1.0.5,更新日期:2020年6月28日 本项目永久地址:https://github.com/YongxinLiu/Microb ...

最新文章

  1. AI换脸鉴别率超99.6%,微软用技术应对虚假信息
  2. Magento利用input type=”file”上传图片
  3. html怎样同框架页面内跳转,使用iframe框架时,实现子页面内跳转到整个页面,而不是在子页面内跳转...
  4. 在5G、大数据、AI领域进行合作,商飞与腾讯云共推大飞机智能制造
  5. hdu1865 1sting
  6. 经典排序算法(二十)--Strand Sort
  7. 【GIS开发者】(GISDeveloper) 11-14期 提供下载
  8. 智能门锁到底安不安全?
  9. 详解如何用爬虫工具批量采集阿里巴巴批发网商品数据
  10. 众多IT精英齐聚首尔,竟是因为这项技术……
  11. 人力资源管理案例选读【1】
  12. 我的第一本人生规划手册_笔记_Part3(完结) - 知乎
  13. 人人商城图片错乱问题
  14. mac 上格式化磁盘出现MediaKit报告设备上的空间不足以执行请求的解决办法
  15. vue 项目中实现按钮防抖
  16. 电信天翼云搭建Halo博客
  17. 获得PMP证书之后该如何获取续证PDU?
  18. [:, None]的作用是什么?
  19. 今日,首款国产超小体积5G通信模组商用!
  20. 浅谈企业拥有门户网站的重要性

热门文章

  1. 论文阅读——INSIDER:Designing In-Storage Computing System for Emerging High-Performance Drive
  2. Go Micro介绍与入门
  3. 字符函数和字符串函数
  4. 暴漏React配置时报错Remove untracked files, stash or commit any changes, and try again.
  5. Python数据挖掘学习——鸢尾花分类、OneR算法
  6. Oracle导入英文日期格式数据出现问题的解决
  7. 主修计算机专业的青年们的一封信(转载)
  8. 设置-安全-手机加密功能解说
  9. 软件工程网络15个人作业3——案例分析(201521123107)
  10. ORACLE实现MySQL中substring_index函数功能