[R] snp-chip table

David Winsemius dwinsemius at comcast.net
Fri Mar 11 13:38:59 CET 2011


On Mar 10, 2011, at 3:58 PM, shai uliel wrote:

> Dear R helpers
> I have a table and i need to make new table
>
>
> table1:
>
>               sire  snp1 snp2 snp3 snp4 snp5 snp6 snp7 snp8 snp9 snp10
> snp11 snp12 snp13 snp14 snp15 8877 -1 -1 -1 -1 0 0 -1 -1 -1 0 1 1 1  
> -1 -1
> 7765 1 1 1 0 0 0 -1 1 1 1 0 0 0 1 0 8766 1 1 -1 0 -1 -1 0 -1 0 -1 -1  
> -1 0 1
> 0 6756 0 1 0 -1 1 -1 -1 0 0 0 0 -1 0 1 1 5644 -1 0 1 -1 0 0 0 0 -1  
> -1 0 0 0
> 0 1

sire  snp1 snp2 snp3 snp4 snp5 snp6 snp7 snp8 snp9 snp10 snp11 snp12  
snp13 snp14 snp15
8877 -1 -1 -1 -1 0 0 -1 -1 -1 0 1 1 1 -1 -1
7765 1 1 1 0 0 0 -1 1 1 1 0 0 0 1 0
8766 1 1 -1 0 -1 -1 0 -1 0 -1 -1 -1 0 1 0
6756 0 1 0 -1 1 -1 -1 0 0 0 0 -1 0 1 1
5644 -1 0 1 -1 0 0 0 0 -1 -1 0 0 0 0 1
>
> I have table2
>     sire snp1 snp2 snp3 snp4 snp5 snp6 snp7 snp8 snp9 snp10 snp11  
> snp12
> snp13 snp14 snp15 8989 1 1 1 1 0 0 -1 -1 1 0 -1 0 1 0 -1
>
>
> i need to ask evry snp if snp1(table2)==snp1(table1)
> but not evry snp alone windows ==15
> if 15 snp are equal then sent line to new table3

I haven't figured out what you are trying to say. It appears you have  
offered an example which would generate NULL output.

You should read the Posting Guide and pay particular attention to the  
request for reproducible examples (and not that HTML mail is severely  
deprecated.) . It suggests using dump(), but I have found that dput is  
easier to remember:

 > dput(table1)
structure(list(sire = c(8877L, 7765L, 8766L, 6756L, 5644L), snp1 =  
c(-1L,
1L, 1L, 0L, -1L), snp2 = c(-1L, 1L, 1L, 1L, 0L), snp3 = c(-1L,
1L, -1L, 0L, 1L), snp4 = c(-1L, 0L, 0L, -1L, -1L), snp5 = c(0L,
0L, -1L, 1L, 0L), snp6 = c(0L, 0L, -1L, -1L, 0L), snp7 = c(-1L,
-1L, 0L, -1L, 0L), snp8 = c(-1L, 1L, -1L, 0L, 0L), snp9 = c(-1L,
1L, 0L, 0L, -1L), snp10 = c(0L, 1L, -1L, 0L, -1L), snp11 = c(1L,
0L, -1L, 0L, 0L), snp12 = c(1L, 0L, -1L, -1L, 0L), snp13 = c(1L,
0L, 0L, 0L, 0L), snp14 = c(-1L, 1L, 1L, 1L, 0L), snp15 = c(-1L,
0L, 0L, 1L, 1L)), .Names = c("sire", "snp1", "snp2", "snp3",
"snp4", "snp5", "snp6", "snp7", "snp8", "snp9", "snp10", "snp11",
"snp12", "snp13", "snp14", "snp15"), class = "data.frame", row.names =  
c(NA,
-5L))
 > dput(table2)
structure(list(sire = 8989L, snp1 = 1L, snp2 = 1L, snp3 = 1L,
     snp4 = 1L, snp5 = 0L, snp6 = 0L, snp7 = -1L, snp8 = -1L,
     snp9 = 1L, snp10 = 0L, snp11 = -1L, snp12 = 0L, snp13 = 1L,
     snp14 = 0L, snp15 = -1L), .Names = c("sire", "snp1", "snp2",
"snp3", "snp4", "snp5", "snp6", "snp7", "snp8", "snp9", "snp10",
"snp11", "snp12", "snp13", "snp14", "snp15"), class = "data.frame",  
row.names = c(NA,
-1L))

This would check for individual "equality of entries:

 > apply(table1[,2:16], 1, "==" , table2[1,2:16])
        [,1]  [,2]  [,3]  [,4]  [,5]
  [1,] FALSE  TRUE  TRUE FALSE FALSE
  [2,] FALSE  TRUE  TRUE  TRUE FALSE
  [3,] FALSE  TRUE FALSE FALSE  TRUE
  [4,] FALSE FALSE FALSE FALSE FALSE
  [5,]  TRUE  TRUE FALSE FALSE  TRUE
  [6,]  TRUE  TRUE FALSE FALSE  TRUE
  [7,]  TRUE  TRUE FALSE  TRUE FALSE
  [8,]  TRUE FALSE  TRUE FALSE FALSE
  [9,] FALSE  TRUE FALSE FALSE FALSE
[10,]  TRUE FALSE FALSE  TRUE FALSE
[11,] FALSE FALSE  TRUE FALSE FALSE
[12,] FALSE  TRUE FALSE FALSE  TRUE
[13,]  TRUE FALSE FALSE FALSE FALSE
[14,] FALSE FALSE FALSE FALSE  TRUE
[15,]  TRUE FALSE FALSE FALSE FALSE

>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list