Skip to content

Instantly share code, notes, and snippets.

@mutolisp
Forked from anonymous/RRTscript.r
Created May 27, 2013 10:39

Revisions

  1. @invalid-email-address Anonymous created this gist May 27, 2013.
    21 changes: 21 additions & 0 deletions RRTscript.r
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    setwd("/Users/easss/Desktop/RRTbatch/")

    library(ape)
    library(pegas)
    # list file in current directory, where the file is end with .phy
    filelist <- list.files(path=".", pattern=".phy$")
    # create a container to store output data
    out_tab <- matrix(0, nrow=length(filelist), ncol=3)
    colnames(out_tab) <- c("dna_seq", "Chi", "Pval")

    i = 1
    for ( f in filelist ) {
    seq3 <- read.dna(f)
    out_tab[i,1] <- f
    out_tab[i,2] <- rr.test(x = seq3[2,], y = seq3[3, ], out = seq3[1, ])$Chi
    out_tab[i,3] <- rr.test(x = seq3[2,], y = seq3[3, ], out = seq3[1, ])$Pval
    i=i+1
    }

    # write output table
    write.table(out_tab, file="out_tab.csv", sep=",", row.names=F)