Group members: Anushka, Paige, Yumi, Kate
import opendatasets as od
import pandas as pd
import os
import numpy as np
import matplotlib.pyplot as plt
from sklearn import linear_model
“finch_beaks_1975.csv” and “finch_beaks_2012.csv”
band
is the identification tag for each birdspecies
encoding as integers:
0 = scandens
1 = fortisBeak length, mm
Beak depth, mm
“fortis_beak_depth_heredity.csv”
Mid-offspr
is the average beak depth between all of the offspring of a set of parentsMale BD
: the beak depth of male parentFemale BD
: the beak depth of the female parent“scandens_beak_depth_heredity.csv”
mid_parent
: the average beak depth of mother and fathermid_offspring
: is the average beak depth between all of the offspring of a set of parentsTo connect these 4 datasets, we are interested in the evolution of the beak depth trait of the two different species of finches, scandens and fortis. fortis_beak_depth_heredity.csv
contains hereditary information, which we can perform OLS regression to get a heredity index equivalent to the $R^2$ of the OLS regression model. We will do the same for the scandens_beak_depth_heredity.csv
data to yield another heredity index for the scandens species. We hypothesize that for both species, the offspring beak depth will be different than their parents, and this will align with the heredity information.
beaks_1975 = pd.read_csv("data/finch_beaks_1975.csv", index_col=0)
beaks_2012 = pd.read_csv("data/finch_beaks_2012.csv", index_col=0)
fortis_heredity = pd.read_csv("data/fortis_beak_depth_heredity.csv")
scandens_heredity = pd.read_csv("data/scandens_beak_depth_heredity.csv")
beaks_1975['species']=(beaks_1975['species']=='fortis').to_numpy().astype(int)
beaks_2012['species']=(beaks_2012['species']=='fortis').to_numpy().astype(int)
beaks_1975 = beaks_1975.rename(columns={"Beak length, mm": "beak_length", "Beak depth, mm": "beak_depth"})
beaks_2012 = beaks_2012.rename(columns={"blength": "beak_length", "bdepth": "beak_depth"})
beaks_1975.head(10)
species | beak_length | beak_depth | |
---|---|---|---|
band | |||
2 | 1 | 9.4 | 8.0 |
9 | 1 | 9.2 | 8.3 |
12 | 1 | 9.5 | 7.5 |
15 | 1 | 9.5 | 8.0 |
305 | 1 | 11.5 | 9.9 |
307 | 1 | 11.1 | 8.6 |
308 | 1 | 9.9 | 8.4 |
309 | 1 | 11.5 | 9.8 |
311 | 1 | 10.8 | 9.2 |
312 | 1 | 11.3 | 9.0 |
# compare the beak measurement in 2012 to 1975
beaks_1975.groupby('species')[['beak_length', 'beak_depth']].mean()
beak_length | beak_depth | |
---|---|---|
species | ||
0 | 14.12092 | 8.960000 |
1 | 10.56519 | 9.171646 |
beaks_2012.groupby('species')[['beak_length', 'beak_depth']].mean()
beak_length | beak_depth | |
---|---|---|
species | ||
0 | 13.421024 | 9.186220 |
1 | 10.517355 | 8.605372 |