当前位置:网站首页>Nichenet actual silicosis
Nichenet actual silicosis
2022-06-30 17:03:00 【youngleeyoung】
############################################https://www.jianshu.com/p/5db596333dfb
#https://cloud.tencent.com/developer/article/1819551
.libPaths()
.libPaths("G:/R_big_packages/")
.libPaths(c("G:/R_big_packages/","D:/Win10 System/Documents/R/win-library/4.1","C:/Program Files/R/R-4.1.0/library"))
.libPaths()
installed.packages()[, c("Package", "LibPath")]
Sys.chmod(.libPaths(),'777')
#library(devtools)
#install_github("saeyslab/nichenetr")
#https://www.jianshu.com/p/c0f3c3728a8d
# If the package cannot be loaded normally , First unloadNamespace These bags !!!!!!!!!!!!!!!!!!!!!!!!!!!!
for (packagename in c("dplyr","recipes","tidyselect",
"dbplyr","tidyr","ggpubr","ggplot2","usethis","broom")) {
unload(packagename)
}
library(nichenetr)
library(Seurat) # please update to Seurat V4
library(tidyverse)
library(ggplot2)
#BiocManager::install("glue")
#library("glue")
sessionInfo()
'''
NicheNet Analysis and practice
Data sources
The analysis data and code of this article come from NicheNet A tutorial on the official analysis of single cell data ,
https://github.com/saeyslab/nichenetr/blob/master/vignettes/seurat_wrapper.md
Demo dataset from Medaglia et al. 2017 “Spatial Reconstruction of Immune Niches by Combining Photoactivatable Reporters and scRNA-Seq.” Science, December, eaao4277.
https://doi.org/10.1126/science.aao4277.
We will use Medaglia Et al NICHE-seq data , To explore lymphocytic choroidal meningitis virus (LCMV) Before infection
And after 72 Hours of inguinal lymph nodes T Intercellular communication in cellular regions .
In this dataset , Steady state CD8 T Cell and LCMV After infection CD8 T There is differential expression between cells .NicheNet It can be used to observe several immune cell populations in lymph nodes
( Monocytes , Dendritic cells ,NK cells ,B cells ,CD4 T cells ) How to regulate and induce these observed gene expression changes .
'''
getwd()
path="G:/silicosis/sicosis/NicheNet/6-30_silisosis"
dir.create(path)
setwd(path)
getwd()
1# Read in single cell data
#seuratObj = readRDS(url("https://zenodo.org/record/3531889/files/seuratObj.rds"))
#save(seuratObj,file = "G:/silicosis/sicosis/NicheNet/seuratobj.rds")
load(file = "G:/silicosis/sicosis/NicheNet/seuratobj.rds")
seuratObj@meta.data %>% head() ##aggregate Is the processing condition ,SS amount to control,LCMV amount to case.
seuratObj@assays$RNA@data[1107:1108,501:505]
2## Read in nichenet A priori data
#ligand_target_matrix <- readRDS(url("https://zenodo.org/record/3260758/files/ligand_target_matrix.rds"))
#save(ligand_target_matrix,file ="G:/silicosis/sicosis/NicheNet/ligand_target_matrix.rds" )
load(file ="G:/silicosis/sicosis/NicheNet/ligand_target_matrix.rds")
head(ligand_target_matrix)[1:4,1:5] # Description is human data
#lr_network = readRDS(url("https://zenodo.org/record/3260758/files/lr_network.rds"))
#save(lr_network,file = "G:/silicosis/sicosis/NicheNet/lr_network.rds")
load(file = "G:/silicosis/sicosis/NicheNet/lr_network.rds")
head(lr_network)
#weighted_networks = readRDS(url("https://zenodo.org/record/3260758/files/weighted_networks.rds"))
#save(weighted_networks,file ="G:/silicosis/sicosis/NicheNet/weighted_networks.rds" )
load(file = "G:/silicosis/sicosis/NicheNet/weighted_networks.rds")
weighted_networks_lr = weighted_networks$lr_sig %>% inner_join(lr_network %>% distinct(from,to), by = c("from","to"))
head(weighted_networks$lr_sig) # interactions and their weights in the ligand-receptor + signaling network
# weighted_networks The list contains two data frames ,lr_sig Is a ligand - Receptor weighted signal network ,gr Is a ligand - Target gene weight regulation network
3 ###
'''
NicheNet analysis
We want to use NicheNet Predict which ligands may affect CD8 T Cells in LCMV Differentially expressed genes after infection .
In this case ‘CD8 T cell’ yes receiver cells ,‘CD4 T’, ‘Treg’, ‘Mono’, ‘NK’, ‘B’ and ‘DC’ yes sender cells .
NicheNet Provides a packaging function nichenet_seuratobj_aggregate, It can be done in one step seurat Analysis of ligand regulatory network of the object .
'''
scRNA=seuratObj
table(scRNA$celltype,scRNA$aggregate)
Idents(scRNA)
Idents(scRNA) <- "celltype"
nichenet_output = nichenet_seuratobj_aggregate(seurat_obj = scRNA,
top_n_ligands = 20,
receiver = "CD8 T",
sender = c("CD4 T","Treg", "Mono", "NK", "B", "DC"),
condition_colname = "aggregate",
condition_oi = "LCMV",
condition_reference = "SS",
ligand_target_matrix = ligand_target_matrix,
lr_network = lr_network,
weighted_networks = weighted_networks,
organism = "mouse")
# top_n_ligands Parameter specifies the number of highly active ligands to be used for subsequent analysis
#save(nichenet_output,file = "nichenet_output.rds")
load(file = "G:/silicosis/sicosis/NicheNet/nichenet_output.rds")
getwd()
4#NicheNet result
## View the results of ligand activity analysis
# Main reference pearson indicators ,bona_fide_ligand=True Represents ligands reported in the literature - Recipient ,
# bona_fide_ligand=False representative PPI Predict ligands that have not been confirmed by experiments - Recipient .
head(nichenet_output)
names(nichenet_output)
x <- nichenet_output$ligand_activities
write.csv(x, "ligand_activities.csv", row.names = F)
5#
# see top20 ligands
nichenet_output$top_ligands
# see top20 ligands Expression in various cell subpopulations
p = DotPlot(scRNA, features = nichenet_output$top_ligands, cols = "RdYlBu") + RotatedAxis()
ggsave("top20_ligands.png", p, width = 12, height = 6)
# Press "aggregate" The expression of ligands was compared
p = DotPlot(scRNA, features = nichenet_output$top_ligands, split.by = "aggregate") + RotatedAxis()
ggsave("top20_ligands_compare.png", p, width = 12, height = 8)
# Compare the expression of ligands with violin diagram
p = VlnPlot(scRNA, features = nichenet_output$top_ligands,
split.by = "aggregate",split.plot = TRUE, pt.size = 0)
ggsave("VlnPlot_ligands_compare.png", p, width = 12, height = 8)
6#
## Look at ligand regulated target genes
p = nichenet_output$ligand_target_heatmap
ggsave("Heatmap_ligand-target.png", p, width = 12, height = 6)
# Change the style of the heat map
p = nichenet_output$ligand_target_heatmap +
scale_fill_gradient2(low = "whitesmoke", high = "royalblue", breaks = c(0,0.0045,0.009)) +
xlab("anti-LCMV response genes in CD8 T cells") +
ylab("Prioritized immmune cell ligands")
ggsave("Heatmap_ligand-target2.png", p, width = 12, height = 6)
# see top Ligand regulated target genes and their scores
x <- nichenet_output$ligand_target_matrix
#x2 <- nichenet_output$ligand_target_df
write.csv(x, "ligand_target.csv", row.names = F)
# Check the expression of target genes regulated by ligands
p = DotPlot(scRNA %>% subset(idents = "CD8 T"),
features = nichenet_output$top_targets,
split.by = "aggregate") + RotatedAxis()
ggsave("Targets_Expression_dotplot.png", p, width = 12, height = 6)
p = VlnPlot(scRNA %>% subset(idents = "CD8 T"), features = nichenet_output$top_targets,
split.by = "aggregate", pt.size = 0, combine = T, ncol = 8)
ggsave("Targets_Expression_vlnplot.png", p, width = 12, height = 8)
7#
## Check the receptor
# See ligands - Receptor interaction
p = nichenet_output$ligand_receptor_heatmap
ggsave("Heatmap_ligand-receptor.png", p, width = 12, height = 6)
x <- nichenet_output$ligand_receptor_matrix
#x <- nichenet_output$ligand_receptor_df
write.csv(x, "ligand_receptor.csv", row.names = F)
# Check the receptor expression
p = DotPlot(scRNA %>% subset(idents = "CD8 T"),
features = nichenet_output$top_receptors,
split.by = "aggregate") + RotatedAxis()
ggsave("Receptors_Expression_dotplot.png", p, width = 12, height = 6)
p = VlnPlot(scRNA %>% subset(idents = "CD8 T"), features = nichenet_output$top_receptors,
split.by = "aggregate", pt.size = 0, combine = T, ncol = 8)
ggsave("Receptors_Expression_vlnplot.png", p, width = 12, height = 8)
# Ligands reported in the literature - Recipient
# Show ‘bona fide’ ligand-receptor links
#that are described in the literature and not predicted based on PPI
p = nichenet_output$ligand_receptor_heatmap_bonafide
ggsave("Heatmap_ligand-receptor_bonafide.png", p, width = 8, height = 4)
x <- nichenet_output$ligand_receptor_matrix_bonafide
#x <- nichenet_output$ligand_receptor_df_bonafide
write.csv(x, "ligand_receptor_bonafide.csv", row.names = F)
边栏推荐
- Dart: string replace related methods
- restartProcessIfVisible的流程
- Data mining knowledge points sorting (final review version)
- [JVM] takes you to learn about the garbage collection mechanism (GC) in the JVM -- including diagrams
- 编译丨迅为iTOP4412开发板Makefile编译
- [BJDCTF2020]The mystery of ip|[CISCN2019 华东南赛区]Web11|SSTI注入
- Tutoriel etcd - chapitre 8 API compacte, Watch et lease pour etcd
- 山西化工园区智能化管控平台建设时间表
- Hologres共享集群助力淘宝订阅极致精细化运营
- 9: Chapter 3: e-commerce engineering analysis: 4: [general module]; (to be written...)
猜你喜欢
Hologres共享集群助力淘宝订阅极致精细化运营
List announced - outstanding intellectual property service team in China in 2021
Restartprocessifvisible process
Niuke.com: minimum cost of climbing stairs
Wechat emoticons are written into the judgment, and the OK and bomb you send may become "testimony in court"
Etcd教程 — 第八章 Etcd之Compact、Watch和Lease API
[Verilog quick start of Niuke online question series] ~ bit splitting and operation
After 15 years of working on 21 types of hardware, where is Google?
JS Es5 can also create constants?
赛芯电子冲刺科创板:拟募资6.2亿 实控人谭健为美国籍
随机推荐
idea必用插件
halcon知识:矩阵专题【02】
华为帐号多端协同,打造美好互联生活
After 15 years of working on 21 types of hardware, where is Google?
MC Instruction Decoder
HMS Core音频编辑服务3D音频技术,助力打造沉浸式听觉盛宴
2020蓝桥杯国赛B组-搬砖-(贪心排序+01背包)
[activity registration] it's your turn to explore the yuan universe! I will be waiting for you in Shenzhen on July 2!
Mathematical modeling for war preparation 34-bp neural network prediction 2
列表变成向量 列表变向量 list vector
JS Es5 can also create constants?
JS ES5也可以创建常量?
【JVM】类加载相关面试题——类加载过程、双亲委派模型
中航无人机科创板上市:市值385亿 拳头产品是翼龙无人机
Delete duplicates in an ordered array ii[double pointers -- unified in multiple cases]
Niuke: how many different binary search trees are there
geo 读取单细胞csv表达矩阵 单细胞 改列名 seurat
《网络是怎么样连接的》读书笔记 - 汇总篇
Hologres共享集群助力淘宝订阅极致精细化运营
[machine learning] K-means clustering analysis