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.
You should not duplicate your post ....
But the duplicates headers contain different values inside the matrix how can i delete those duplicates? i need those duplicate headers
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.
because these are different mutations of same gene
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
Cross posted at StackOverflow, and closed as duplicate, see linked posts there.
Thank you but those answers are not working for me