Open jsl-netizen opened 1 week ago
Hi, Thank you for using OFF-PEAK and for reporting the issue. I modified one line in 03_OFF-PEAK.R that should fix the bug. Can you try with the new script? Best, Mathieu
Hi thank you for your quick answer with the new script i get : Rscript 03_OFF-PEAK.R --output output_directory --data output_directory/ALL.target.tsv --databasefile data/data-hg38.RData
Attaching package: ‘gplots’
The following object is masked from ‘package:stats’:
lowess
Type 'citation("pROC")' for a citation.
Attaching package: ‘pROC’
The following objects are masked from ‘package:stats’:
cov, smooth, var
Error in seq.default(min(max(min(correlation), 0), 0.95), 1, length.out = 71) : 'from' must be a finite number Calls: heatmap.2 -> duplicated -> seq -> seq.default Execution halted
when id o this modification :
# Correlation between samples (heatmap and text output)
{
# res is matrix for correlations
num = dim(dataALL)[2]
if (num - 4 <= 5) {
stop(paste("You need to analyze at least 6 samples to run OFF-PEAK. You provided ", num - 4, " samples. Exit.", sep = ""))
}
correlation = matrix(nrow = (num - 4), ncol = (num - 4))
colnames(correlation) = colnames(dataALL)[5:dim(dataALL)[2]]
rownames(correlation) = colnames(dataALL)[5:dim(dataALL)[2]]
# selecting targets with signal and noise limits
meanALL = apply(dataALL[, 5:num], 1, mean)
sdALL = apply(dataALL[, 5:num], 1, sd)
ok = which(meanALL > minsignal & dataALL[, 1] != "chrX" & log10(sdALL / meanALL) < maxvar)
# downsampling targets to 10'000 for quick computation
if (length(ok) > 10000) {
ok = ok[sample(1:length(ok), 10000, replace = FALSE)]
}
selection = dataALL[ok, 5:num]
# computing correlations
for (i in 1:(num - 4)) {
for (j in 1:(num - 4)) {
correlation[i, j] = cor(selection[, i], selection[, j])
}
}
# Check and handle non-finite values in the correlation matrix
correlation[!is.finite(correlation)] = 0
# Calculate the minimum value of the correlation matrix after replacing non-finite values
min_correlation = min(correlation, na.rm = TRUE)
# plotting heatmap of correlation and writing output to text file
pdf(file = paste(folder, "/01_general-stats/Heatmap-correlations-all.pdf", sep = ""), width = 7, height = 7)
par(mfrow = c(1, 1))
heatmap.2(
correlation,
cexRow = 0.1,
cexCol = 0.1,
breaks = seq(min_correlation, 1, length.out = 71),
trace = "none",
col = colorRampPalette(c("red", "orange", "yellow", "green"))(n = 70)
)
dev.off()
correlation2 = cbind(rownames(correlation), correlation)
correlation2 = rbind(colnames(correlation2), correlation2)
write.table(correlation2, file = paste(folder, "/01_general-stats/Pairwise-correlations-all.tsv", sep = ""), quote = FALSE, sep = "\t", row.names = FALSE, col.names = FALSE)
}
The correlation[!is.finite(correlation)] = 0 line replaces any non-finite values (like NA, NaN, Inf, -Inf) in the correlation matrix with zero. The min_correlation = min(correlation, na.rm = TRUE) line calculates the minimum value of the correlation matrix after replacing non-finite values. The seq(min_correlation, 1, length.out = 71) ensures that the breaks parameter in the heatmap.2 function uses a finite minimum value.
the process go through but i dont know if i should change the line like that
I am in the process for testing with hg19 because on your publication it seems thats it works with it i will tell you
the tools works well with hg19 so i think maybe it is a problem with the hg38 build
Thank you for checking! In fact the script 03_OFF-PEAK.R is not different for hg19 and hg38 so I don't understand the issue. Could you add the following line at line 973: write.table(correlation,file=paste(folder,"/01_general-stats/correlation-test.tsv",sep=""),quote=F,sep="\t") Then have a look at the numbers and also at the plot 01_general-stats/Heatmap-correlations-all.pdf
thank you for your time,
I get this file i think something sketchy is happening in my bam. I will investigate this correlation-test.csv
Hi i have got that error message while trying to run the Rscript 03_OFF-PEAK.R on 58 sample. Rscript 03_OFF-PEAK.R \ --output output_directory \ --data output_directory/ALL.target.tsv \ --databasefile data/data-hg38.RData
Attaching package: ‘gplots’
The following object is masked from ‘package:stats’:
Type 'citation("pROC")' for a citation.
Attaching package: ‘pROC’
The following objects are masked from ‘package:stats’:
Error in seq.default(min(correlation), 1, length.out = 71) : 'from' must be a finite number Calls: heatmap.2 -> duplicated -> seq -> seq.default Execution halted
the head of my excel ALL.target.tsv look like this.
I dont find the solution wihtout modifying the script is it normal or did i make a mistake