【发布时间】:2021-02-04 01:38:00
【问题描述】:
我想找到一个基因与其他基因的相关性。最后我会把这个函数变成闪亮的。
我的意思是当我选择输入一个基因时,我可以得到有多少其他基因与这个基因密切相关。并且这些相关基因可以在主面板输出,甚至可以作为文本或excel文件下载。
请原谅我不恰当的表达,因为我是新手。
我的样本 FPKM 基因计数如下:
## library(shiny)
## library(dplyr)
## library(tidyr)
## library(ggplot2)
###
mean_data <- data.frame(
Name = c(paste0("Gene_", LETTERS[1:20])),
matx <- matrix(sample(1:1000, 1000, replace = T), nrow = 20)
)
names(mean_data)[-1] <- c(paste0("Sample_", 1:50))
rownames(mean_data)<-mean_data[,1]
mean_data<-mean_data[,-1]
## I don't know the code below is right or not . But I wanna the correlation between the input one and the others
corResult=apply(mean_data,1,function(x){
cor(x[1:25],x[26:50],method="spearman")
})
hist(corResult)
corResult_test=apply(mean_data,1,function(x){
cor.test(x[1:25],x[26:50],method="spearman",exact = F)$p.value
})
table(abs(corResult)>0.65 & corResult_test<0.05)
有人可以帮助我吗?给我一个合适的方法。
感激不尽。
【问题讨论】:
标签: r shiny correlation