趋势线和​​斜率(R)

时间:2017-12-23 16:25:56

标签: r

我正在尝试研究这种蛋白质相互作用网络。我需要做一个边缘度数分布图(代码的最后一行),但我不能制作趋势线和斜率(代码的最后一行)。有人能帮帮我吗?

template<typename T, std::enable_if_t<has_fun<T>::value> * = nullptr>
struct C
{
 void fun()
 { ... }
};
template<typename T, std::enable_if_t<!has_fun<T>::value> * = nullptr>
struct C
{
  // no fun()
};

1 个答案:

答案 0 :(得分:0)

您将abline放在log10-log10刻度上的情节中。这是实现目标的一种方式

您的代码

library("igraph")
tfile<-tempfile()
download.file("http://pdg.cnb.uam.es/pazos/tmp/Yeast_int.txt", tfile)
datosraw <- subset(read.delim(tfile, sep="\t", header=F, stringsAsFactors = F), !is.na(V3) & V3!="" & V3!="METHOD")
names(datosraw)<-c("orf1","orf2","method")
datos<-split(datosraw,datosraw$method)
df.y2h <- graph.data.frame(d = datos$Y2H[1:5125,c(1,2)], directed = FALSE)

其余部分可以包含在辅助函数中

plot_degree_distribution = function(graph) {
  # calculate degree
  d = degree(graph, mode = "all")
  dd = degree.distribution(graph, mode = "all", cumulative = FALSE)
  degree = 1:max(d)
  probability = dd[-1]
  # delete blank values
  nonzero.position = which(probability != 0)
  probability = probability[nonzero.position]
  degree = degree[nonzero.position]
  # plot
  plot(probability ~ degree, log = "xy", xlab = "Degree (log)", ylab = "Probability (log)", 
       col = 1, main = "Degree Distribution")
  abline(lm(log10(probability) ~ log10(degree)))
}

plot_degree_distribution(df.y2h)

log10-log10