分享

Nichenetr V2(二):推断ligands-target信号途径

 TS的美梦 2024-10-24

内容获取

1、购买打包合集(《KS科研分享与服务》付费内容打包集合),价格感人,可以加入微信VIP群(答疑交流群,甚至有小伙伴觉得群比代码更好),可以获取建号以来所有内容,群成员专享视频教程,提前更新,其他更多福利!

2、《KS科研分享与服务》公众号有QQ群,进入门槛是20元(完全是为了防止白嫖党,请理解),请考虑清楚。群里有免费推文的注释代码和示例数据(终身拥有),没有付费内容,群成员福利是购买单个付费内容半价!

需要者详情请联系作者(非需要者勿扰,处理太费时间):

关于nichenetr基础分析请参考:都有详细的介绍以及可视化。
【视频教程】Nichenetr V2(一):单细胞通讯分析基础流程及可视化修饰
Github:https://github.com/saeyslab/nichenetr/tree/master?tab=readme-ov-file#background。
nichenetr还能推断ligands-target信号途径,它的先验模型中提供了ligand-tf-matrix,以及sig_network,为了确定配体与目标蛋白之间的信号途径,首先需要查看哪些转录因子最可能调控目标基因,并且与配体的距离最近。然后,确定这些转录因子与感兴趣的配体之间的最短路径,并将参与该路径的基因视为重要的信号传递介质。最后,模型数据中查找所有配体、信号传递介质、转录因子和目标基因之间的相互作用。这样整个分析就形成了一个很好的路径,lingands-receptor-target-sig。请注意,本教程已包含在之前的Nichenetr V2(一)

首先需要加载必须的数据库模型,如果链接读取不成功,建议自己下载读入。

#首先需要加载必须的数据库模型,如果链接读取不成功,建议自己下载读入library(nichenetr)library(tidyverse)library(DiagrammeR)
weighted_networks <- readRDS('./nichent-human-network/weighted_networks_nsga2r_final.rds')ligand_tf_matrix <- readRDS('./nichent-human-network/ligand_tf_matrix_nsga2r_final.rds')
lr_network <- readRDS('./nichent-human-network/lr_network_human_21122021.rds')sig_network <- readRDS('./nichent-human-network/signaling_network_human_21122021.rds')gr_network <- readRDS('./nichent-human-network/gr_network_human_21122021.rds')

需要分析哪个liangs和target的关系,可以自定义:然后提取配体和感兴趣的靶基因之间可能的信号通路,并提取权重最高的路径。

#定义感兴趣的ligands和target,这取决于你自己研究ligands_oi <- "LRPAP1" targets_oi <- c("CDKN1A","VEGFA")
#Extract possible signaling paths between a ligand and target gene of interest. The most highly weighted path(s) will be extracted.ligand_target_signaling_list <- get_ligand_signaling_path(ligands_all = ligands_oi, targets_all = targets_oi, weighted_networks = weighted_networks, ligand_tf_matrix = ligand_tf_matrix, top_n_regulators = 4,#The number of top regulators that should be included in the ligand-target signaling network. minmax_scaling = TRUE) #标准化边缘权重

最后可视化网络:保存图片。

#Prepare extracted ligand-target signaling network for visualization with DiagrammeR.graph_min_max <- diagrammer_format_signaling_graph(signaling_graph_list = ligand_target_signaling_list,                                                   ligands_all = ligands_oi, targets_all = targets_oi,                                                   sig_color = "indianred", gr_color = "steelblue")


head(graph_min_max$edges_df)# id from to rel penwidth color# 1 1 1 3 <NA> 1.3659550 indianred# 2 2 1 4 <NA> 1.4384229 indianred# 3 3 1 6 <NA> 1.1312300 indianred# 4 4 1 7 <NA> 0.8400395 indianred# 5 5 1 8 <NA> 0.8034608 indianred# 6 6 1 10 <NA> 0.8951246 indianred
head(graph_min_max$nodes_df)# id type label nodes style width fillcolor fontcolor# APP 1 <NA> APP 1 filled 0.75 grey50 white# ESR1 2 <NA> ESR1 2 filled 0.75 grey50 white# JUN 3 <NA> JUN 3 filled 0.75 grey50 white# LRP1 4 <NA> LRP1 4 filled 0.75 grey50 white# LRPAP1 5 <NA> LRPAP1 5 filled 0.75 indianred white# MAPK1 6 <NA> MAPK1 6 filled 0.75 grey50 white

#可视化graph_svg <- DiagrammeRsvg::export_svg(DiagrammeR::render_graph(graph_min_max, layout = "tree", output = "graph"))cowplot::ggdraw() + cowplot::draw_image(charToRaw(graph_svg))

可以将数据导出为cytoscape可视化,我没有尝试,因为不咋用这个软件,其实可以自己做网络图,igraph,ggraph,ggneteork等等很多。这里是官网导出为cytoscape数据的示例:请参考

output_path <- ""write_output <- FALSE # change to TRUE for writing output
# weighted networks ('import network' in Cytoscape)if(write_output){ bind_rows(active_signaling_network$sig %>% mutate(layer = "signaling"), active_signaling_network$gr %>% mutate(layer = "regulatory")) %>% write_tsv(paste0(output_path,"weighted_signaling_network.txt")) }
# networks with information of supporting data sources ('import network' in Cytoscape)if(write_output){ data_source_network %>% write_tsv(paste0(output_path,"data_source_network.txt"))}
# Node annotation table ('import table' in Cytoscape)specific_annotation_tbl <- bind_rows( tibble(gene = ligands_oi, annotation = "ligand"), tibble(gene = targets_oi, annotation = "target"), tibble(gene = c(data_source_network$from, data_source_network$to) %>% unique() %>% setdiff(c(targets_oi,ligands_oi)) %>% intersect(lr_network$to %>% unique()), annotation = "receptor"), tibble(gene = c(data_source_network$from, data_source_network$to) %>% unique() %>% setdiff(c(targets_oi,ligands_oi)) %>% intersect(gr_network$from %>% unique()) %>% setdiff(c(data_source_network$from, data_source_network$to) %>% unique() %>% intersect(lr_network$to %>% unique())),annotation = "transcriptional regulator"))non_specific_annotation_tbl <- tibble(gene = c(data_source_network$from, data_source_network$to) %>% unique() %>% setdiff(specific_annotation_tbl$gene), annotation = "signaling mediator")
if(write_output){ bind_rows(specific_annotation_tbl, non_specific_annotation_tbl) %>% write_tsv(paste0(output_path,"annotation_table.txt"))}
这样就完成了。希望对你有用!

觉得我们分享有些用的,点个赞再走呗!

关注我们获取精彩内容:

    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约