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]) |
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
#Let's say we have a dataset of images of cats and dogs, and we want to train a | |
# model to classify them correctly. We will be using the tf.keras module, which | |
# provides a high-level API for building and training neural networks. | |
import tensorflow as tf | |
from tensorflow import keras | |
# load dataset | |
(x_train, y_train), (x_val, y_val) = keras.datasets.cifar10.load_data() |
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
from sklearn.neural_network import MLPClassifier | |
from sklearn.datasets import load_iris | |
from sklearn.model_selection import train_test_split | |
# Load data | |
iris = load_iris() | |
X = iris.data | |
y = iris.target | |
# Split data into training and testing sets |
NewerOlder