Hello,

I have a matrix of samples (rows) and haplotypes (columns), where 0
indicates that a sample does not posses that columns haplotype and 1
indicates it does. So sample1 has 0's for every column, except the column
that represents haplotype X, and it has a 1.


I want a length(sample) x 2 dataframe that tells me which samples have what
haplotype.

I need some way of identifying for every row, where is the 1? And then
print that information in a new column so I can see what row and which
haplotype.

Here is an example of what I mean:

mat <- matrix(data = c(1,0,0,0,1,0,0,0,1), nrow = 3, byrow = T)

rownames(mat) <- c("AL", "MS", "FL")

> mat

   [,1] [,2] [,3]

AL    1    0    0

MS    0    1    0

FL    0    0    1


How can I make a data frame like this:

AL 1

MS 2

FL 3


Thanks for your ideas and time,

Karl

	[[alternative HTML version deleted]]

