User Tools

Site Tools


mkatari-bioinformatics-august-2013-convert-snp

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

mkatari-bioinformatics-august-2013-convert-snp [2013/08/19 17:35] (current)
mkatari created
Line 1: Line 1:
 +[[mkatari-bioinformatics-august-2013|Back to Manny'​s Bioinformatics Workshop Home]]
  
 +====== Converting SNP Format ======
 +
 +This is not the most efficient way to process this, however intuitively its the simplest.
 +
 +Initialize vectors to save output which can be combined later
 +
 +<​code>​
 +snpcol=character()
 +gencol=character()
 +allelesa=character()
 +allelesb=character()
 +confcol=character()
 +</​code>​
 +
 +The number of rows for final output
 +<​code>​
 +rowcounter=1
 +</​code>​
 +
 +Foreach snp
 +
 +<​code>​
 +for (i in 1:​ncol(snponly)) {
 +    #foreach genotype
 +    for (j in 1:​nrow(snponly)) {
 +      ​
 +      #only do steps if value is not NA
 +      if (!is.na(snponly[j,​i])) {              ​
 +        alleles = unlist(strsplit(as.character(snponly[1,​1]),​ ""​))
 +        snpcol[rowcounter]=colnames(snponly)[i]
 +        gencol[rowcounter]=rownames(snponly)[j]
 +        allelesa[rowcounter]=alleles[1]
 +        allelesb[rowcounter]=alleles[2]
 +        confcol[rowcounter]="​1"​
 +        rowcounter=rowcounter+1
 +      } 
 +      ​
 +    }
 +}
 +</​code>​
mkatari-bioinformatics-august-2013-convert-snp.txt · Last modified: 2013/08/19 17:35 by mkatari