forked from heavywatal/practice-py
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf20eb4
commit 94f157a
Showing
3 changed files
with
36 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,39 @@ | ||
import csv | ||
import pandas as pd | ||
from population import Population | ||
|
||
|
||
def change_allelewf(population): | ||
fit_list = population.get_fitnesses() | ||
fixprocess = [1 - fit_list.count(1.0)/len(fit_list)] | ||
t = 0 | ||
fixprocess = [[t, population.get_mutantfreq()]] | ||
while population.mutation_is_not_fixed(): | ||
t += 1 | ||
population.next_genwf() | ||
fit_list = population.get_fitnesses() | ||
mutantrate = 1 - fit_list.count(1.0)/len(fit_list) | ||
fixprocess.append(mutantrate) | ||
fixprocess.append([t, population.get_mutantfreq()]) | ||
return fixprocess | ||
|
||
|
||
def change_allelemo(population): | ||
fit_list = population.get_fitnesses() | ||
fixprocess = [1 - fit_list.count(1.0)/len(fit_list)] | ||
t = 0 | ||
fixprocess = [[t, population.get_mutantfreq()]] | ||
while population.mutation_is_not_fixed(): | ||
t += 1 | ||
population.next_genmo() | ||
fit_list = population.get_fitnesses() | ||
mutantrate = 1 - fit_list.count(1.0)/len(fit_list) | ||
fixprocess.append(mutantrate) | ||
fixprocess.append([t, population.get_mutantfreq()]) | ||
return fixprocess | ||
|
||
|
||
csvfile1 = open("allelechangewf.csv", "w", encoding="utf-8") | ||
writer = csv.writer(csvfile1) | ||
p1 = Population(10, 0.1, 0.5) | ||
writer.writerow(change_allelewf(p1)) | ||
fixprocesswf = change_allelewf(p1) | ||
writer.writerow(["generation", "derived_allele_frequency"]) | ||
for x in range(len(fixprocesswf)): | ||
writer.writerow(fixprocesswf[x]) | ||
|
||
|
||
p2 = Population(10, 0.1, 0.5) | ||
print(change_allelemo(p2)) | ||
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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
install.packages("tidyverse") | ||
library("tidyverse") | ||
allelefreq=read_csv("~/github/practice-py/hamazaki1990/allelechangewf.csv", col_names = FALSE) | ||
names(allelefreq)=c("generation","derived_allele_frequency") | ||
freqprot=ggplot(allelefreq, x=generation, y=derived_allele_frequency) | ||
freqprot=freqprot+geom_line() | ||
print(freqprot) | ||
freq <- read_csv("~/github/practice-py/hamazaki1990/allelechangewf.csv") | ||
freq | ||
freqplot <- ggplot(freq, aes(x = generation, y = derived_allele_frequency)) | ||
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) |