Entering edit mode
3.7 years ago
Bioinfonext
▴
470
I am using the below code to read a tab-delimited file which has spaces in the header name and these spaces converted into dots while plotting with corrplot.
Could anyone please help how I can avoid space to dot conversion?
library(vegan)
library(phyloseq)
library(ggplot2)
library(magrittr)
library(dplyr)
library(reshape2)
library(RColorBrewer)
library(readxl)
library(corrplot)
library("PerformanceAnalytics")
library("Hmisc")
library(psych)
list.files()
A <- read.table("Spearman.count.FINAL.txt",header=T, sep="\t",check.names=F)
# Convert the first column to be row names
B <- A[, -1]
C <- data.frame(B, row.names=A$Sample)
M = as.matrix(C)
#View(M)
#--------------------Calculate correlation matrix and p-value matrix------------------------#
#-------------------------------------spearman---------------------------------------------#
cor_5 <- rcorr(as.matrix(M),type=c("spearman"))
r_mat <- cor_5$r
p_mat <- cor_5$P
# Extract the r and p (only Euka vs Bac, no inner correlations e.g. bac-bac)
r = r_mat[1:9,10:191]
p = p_mat[1:9,10:191]
# Only consider the positive correlation (r>0)
r_0 = r*(r> 0 )
Many thanks
A general solution for keeping spaces is to put individual header names in quotation marks. Don't know if that will be helpful with this package.
At what step in your code are they getting converted from spaces to dots?
hello rpolicastro ,
Could you please help me how I can investigate this issue step by step?
Thanks,
Use, 'check.names = FALSE'' in read.twble function.
Nothing is working from all the above suggestions. I am not sure at which step, spaces are converted in dots.
Thanks,
Thank you all. I have resolved this problem by substituting dot with space in the end.
Thanks,