Skip to content

Commit

Permalink
solved heavywatal#20
Browse files Browse the repository at this point in the history
  • Loading branch information
hamazaki1990 committed May 19, 2017
1 parent 94f157a commit 11be657
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 26 deletions.
1 change: 0 additions & 1 deletion hamazaki1990/allelechangewf.csv

This file was deleted.

29 changes: 14 additions & 15 deletions hamazaki1990/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,17 @@ def change_allelemo(population):
return fixprocess


csvfile1 = open("allelechangewf.csv", "w", encoding="utf-8")
writer = csv.writer(csvfile1)
p1 = Population(10, 0.1, 0.5)
fixprocesswf = change_allelewf(p1)
writer.writerow(["generation", "derived_allele_frequency"])
for x in range(len(fixprocesswf)):
writer.writerow(fixprocesswf[x])

csvfile2 = open("allelechangemo.csv", "w", encoding="utf-8")
writer = csv.writer(csvfile2)
p1 = Population(10, 0.1, 0.5)
fixprocessmo = change_allelemo(p1)
writer.writerow(["generation", "derived_allele_frequency"])
for x in range(len(fixprocessmo)):
writer.writerow(fixprocessmo[x])
def output_allelechange(filename, population, function):
with open(filename, "w", encoding="utf-8") as outfile:
writer = csv.writer(outfile)
writer.writerow(["generation", "derived_allele_frequency"])
fixprocess = function(population)
for x in range(len(fixprocess)):
writer.writerow(fixprocess[x])


p1 = Population(10, 0.1, 0.2)
output_allelechange("allelefreqwf.csv", p1, change_allelewf)

p2 = Population(10, 0.1, 0.5)
output_allelechange("allelefreqmo.csv", p2, change_allelemo)
21 changes: 11 additions & 10 deletions hamazaki1990/visualize.r
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
library("tidyverse")
freq <- read_csv("~/github/practice-py/hamazaki1990/allelechangewf.csv")
freq
freqplot <- ggplot(freq, aes(x = generation, y = derived_allele_frequency))
freqplot <- freqplot + geom_line()
setwd("~/github/practice-py/hamazaki1990/")
freq_wf <- read_csv("allelefreqwf.csv") %>%
dplyr::mutate(model = "wf")
freq_wf
freq_mo <- read_csv("allelefreqmo.csv") %>%
dplyr::mutate(model = "moran")
freq_mo
freq <- dplyr::bind_rows(freq_wf, freq_mo)
print(freq)
freqplot <- ggplot(freq, aes(x=generation, y=derived_allele_frequency, group=model, color=model))
freqplot <-freqplot + geom_line()
print(freqplot)

freq1 <- read_csv("~/github/practice-py/hamazaki1990/allelechangemo.csv")
freq1
freqplot1 <- ggplot(freq1, aes(x = generation, y = derived_allele_frequency))
freqplot1 <- freqplot1 + geom_path(size=2, linetype="dashed")
print(freqplot1)

0 comments on commit 11be657

Please sign in to comment.