我有一个表,其中包含三种条件(样本)下基因的倍数变化数据。我的数据是:
> dput(df2)
structure(list(Samples = c("A-1", "A-2", "A-4", "B-1", "B-2",
"B-4", "C-1", "C-2", "C-4"), gene1 = c(1.92240792088036, 1.87118633447253,
1.94158574768122, 0.743982725531221, 0.986224813365175, 0.476215748248648,
0.731490064245346, 0.596064876825191, 0.571791594329927), gene2 = c(1.38762620120341,
4.66680898951508, 2.87307760165737, 0.998905293967859, 1.58490494045631,
1.07311974444822, 4.88661528392309, 3.35118753924545, 6.52812574494532
), gene3 = c(2.75218521855555, 1.96606424938052, 1.26134206679715,
0.248847419775807, 0.216994140810077, 0.381075639652472, 0.614240099166926,
0.346259723181132, 0.501984000812794)), class = c("tbl_df", "tbl",
"data.frame"), row.names = c(NA, -9L))
我想在R中计算相关矩阵和p值,然后将其导入Cytoscape进行表达相关任务。
我使用以下代码:
# Transpose the data frame
transposed_df <- t(df)
# Convert row names to a column
transposed_df <- data.frame(Condition = rownames(transposed_df), transposed_df)
# Make the 'Condition' column as row names
rownames(transposed_df) <- transposed_df$Condition
# Remove the 'Condition' column
transposed_df$Condition <- NULL
# Save the transposed data frame as a .csv file
write.xlsx(transposed_df, file = "TransposedDataFrame.xlsx")
# Calculate the correlation matrix
correlation_matrix <- cor(transposed_df, method = "spearman")
但是,但是我面临以下错误:
cor(transpose_df, method = "spearman") 中的错误:'x' 必须是数字
以下是在单个 R 脚本中执行相关基因表达和 Cytoscape 可视化的工作流程:https://cytoscape.org/cytoscape-automation/for-scripters/R/notebooks/Top-genes-and-coexpress.nb。 html.