Error in read.table(file = file, header = header, sep = sep, quote = quote, : duplicate 'row.names' are not allowed
1
0
Entering edit mode
5.6 years ago
xxxxxxxx ▴ 20

my matrix is like this- 13367*13367 long matrix-

        NBAS    DNAH9   NRAS    NRAS    TP53    TP53    TP53    SCYL2   RNF19A
    NBAS    1   0   0   0   0   0   0   0   0
    DNAH9   0   1   0   0   0   0   0   0   0
    NRAS    0   0   1   0   0   0   0   0   0
    NRAS    0   0   0   1   0   0   0   0   0
    TP53    0   0   0   0   1   0   0   0   0
    TP53    0   0   0   0   0   1   0   0   0
    TP53    0   0   0   0   0   0   1   0   0
    SCYL2   0   0   0   0   0   0   0   1   0
    RNF19A  0   0   0   0   0   0   0   0   1

I need to extract all pairs of rows and column headers for which the value is equal to 1 . I m using the following R script-

Pmatrix = read.csv ("file.csv", header= TRUE, row.names = 1)
sig_values <- which(Pmatrix==1, arr.in=TRUE)
cbind.data.frame(colIDs = colnames(Pmatrix)[ sig_values[, 1] ],rowIDs = rownames(Pmatrix)[ sig_values[, 2] ])

but getting error-

Error in read.table(file = file, header = header, sep = sep, quote = quote,  : 
  duplicate 'row.names' are not allowed

If I will put row.names = False R will assume no rownames and add numbering instead. But i need the row names and column names not the numbers.

R r rstudio csv matrix • 5.7k views
ADD COMMENT
0
Entering edit mode

You should not duplicate your post ....

ADD REPLY
0
Entering edit mode

But the duplicates headers contain different values inside the matrix how can i delete those duplicates? i need those duplicate headers

ADD REPLY
0
Entering edit mode

Why are there multiple TP53 entries? Rather than appending suffixes to the row/column names, or similarly modifying on import - work out why you ended up with duplicated gene symbols in this dataset and fix that.

ADD REPLY
0
Entering edit mode

because these are different mutations of same gene

ADD REPLY
2
Entering edit mode

Not without further information they aren't. Supposing your desired workflow worked and you were able to show that TP53 and BRAF were co mutated or whatever, and you printed out "TP53\tBRAF". When you come back to the dataset, how will you know which of the different TP53 mutations it was that associates with BRAF? Get your data annotated such that you can disambiguate one row from another and one column from another. Do this before you export the matrix; and if you do that, the matrix will import properly, because the rownames will be unique

ADD REPLY
0
Entering edit mode

Cross posted at StackOverflow, and closed as duplicate, see linked posts there.

ADD REPLY
0
Entering edit mode

Thank you but those answers are not working for me

ADD REPLY
1
Entering edit mode
5.6 years ago

Throw a "_1", "_2", etc on those non-unique names to make them unique.

ADD COMMENT

Login before adding your answer.

Traffic: 1784 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6