Overwrite matrix as default
iskandari opened this issue · comments
Alexander Tedeschi commented
Suggestion to change the default mode to overwrite, or to create a parameter that specifies write mode as "append" or "overwrite". As it is, WriteMatrixToFile
silently appends if the filename is the same.
WriteMatrixToFile <- function (tmpMatrix, tmpFileName, blnRowNames, blnColNames)
{
output <- file(tmpFileName, "at") # change "at" to "wt"
utils::write.table(tmpMatrix, output, sep = "\t", quote = FALSE,
row.names = blnRowNames, col.names = blnColNames)
close(output)
}
If we follow the multiClust
vignette, for example:
> WriteMatrixToFile(tmpMatrix=data.log,
+ tmpFileName="GSE2034.normalized.expression.txt",
+ blnRowNames=TRUE, blnColNames=TRUE)
> data.exprs <- input_file(input="GSE2034.normalized.expression.txt")
[1] "The gene expression matrix has been loaded"
> dim(data.exprs)
[1] 22283 286
> WriteMatrixToFile(tmpMatrix=data.log,
+ tmpFileName="GSE2034.normalized.expression.txt",
+ blnRowNames=TRUE, blnColNames=TRUE)
> data.exprs <- input_file(input="GSE2034.normalized.expression.txt")
Error in `.rowNamesDF<-`(x, value = value) :
duplicate 'row.names' are not allowed