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
# One sample t assuming a population mean of 15 | |
data <- c(13, 14, 13, 12, 14, 15, 16, 13, 14, 12) | |
t.test(data, mu = 15) | |
# Paired t test | |
group1 <- c(14, 12, 13, 12, 15, 12, 15, 15, 12, 13) | |
group2 <- c(12, 15, 14, 12, 13, 13, 14, 13, 12, 12) | |
t.test(group1, group2, paired = TRUE) |
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
# Calculating mean, and other summary statistics in Python with examples | |
import pandas as pd | |
import numpy as np | |
from palmerpenguins import load_penguins | |
penguins = load_penguins() | |
bill_length_mm = penguins['bill_length_mm'].dropna() |
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
# Exporting data as a .csv in R | |
write.csv(iris, "iris_export.csv", row.names = FALSE) |
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
# Subsetting data in R | |
# Subset Iris data into a dataframe with only one species | |
virginica <- subset(iris, iris$Species == "virginica") | |
# Subset a particular vector with only the values from a particular group | |
virginica_sepals <- iris$Sepal.Length[iris$Species == "virginica"] |
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
## Hardy Weinberg script (2) | |
## Simulating changes in genotype frequencies over time | |
## under 100% selection against homozygous recessive | |
## Instruction: Press "-->Source" | |
##################### CODE: Ignore all of this below ########################### | |
for (i in 1) { |
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
## Hardy Weinberg script (3) | |
## Simulating changes in genotype frequencies over time | |
## under 20% selection against homozygous recessive | |
## Instruction: Press "-->Source" | |
##################### CODE: Ignore all of this below ########################### | |
for (i in 1) { |
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
## Hardy Weinberg script (1) | |
## Simulating changes in genotype frequencies over time | |
## under Hardy-Weinberg Equilibrium | |
## Instruction: Press "-->Source" | |
##################### CODE: Ignore all of this below ########################### | |
BB.f <- NA |
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
# Survival analysis in R | |
# Load library (install first if needed) | |
library(survival) | |
library(survMisc) | |
# create a sample data set | |
data <- lung | |
# fit a survival model |
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
# Running a principal components analysis (PCA) in Python | |
#%% | |
import pandas as pd | |
# pip install scikit-learn | |
from sklearn.decomposition import PCA | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
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
# Running a principal components analysis (PCA) in R | |
# Load data | |
data(iris) | |
# Remove factors | |
data <- iris | |
# Scale data | |
data_scaled <- scale(data[-5]) |
NewerOlder