This file contains hidden or 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
import os | |
import shutil | |
import requests | |
import urllib | |
from urllib.request import urlretrieve | |
canvas_token = os.environ["CANVAS_TOKEN"] | |
resp = requests.get( | |
url=f"https://canvas.ubc.ca/api/v1/courses/19078/assignments/313587/gradeable_students", | |
headers={ |
This file contains hidden or 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
# assumes instructor's Canvas token is stored as an environmental variable called CANVAS_TOKEN | |
import os | |
import requests | |
canvas_token = os.environ["CANVAS_TOKEN"] | |
resp = requests.get( | |
url=f"https://canvas.ubc.ca/api/v1/courses/19078/enrollments", | |
headers={ | |
"Authorization": f"Bearer {canvas_token}", | |
"Accept": "application/json+canvas-string-ids" |
This file contains hidden or 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
import pandas as pd | |
from gapminder import gapminder | |
def nest(grouped_data): | |
'''Takes in a grouped data frame''' | |
groups = [] | |
datas = [] | |
for group in grouped_data.groups: | |
groups.append(group) | |
datas.append(grouped_data.get_group(group)) |
This file contains hidden or 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
set.seed(123) | |
for(n in c(50, 200, 500, 1000, 2000, 10000) ) { | |
x1 <- data.frame(x1 = rnorm(n, 3), x2 = rnorm(n, 3)) | |
x2 <- data.frame(x1 = rnorm(n, -2), x2 = rnorm(n, -2)) | |
x <- rbind(x1, x2) | |
a <- kmeans(x, centers= 2) | |
print(paste0('Sample size: ', n, ' - between_SS / total_SS: ', round(100 * a$betweenss/a$totss, 2))) | |
} |
- Ten Simple Rules for a Computational Biologist’s Laboratory Notebook
- Lab manager, experiment notebook, database for research labs
- Jupyter notebook
- Rmd notebook in Rstudio
- Nextjournal
- blogdown
- Benchling
This file contains hidden or 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
library(tidyverse) | |
library(grid) | |
f <- file("/dev/cu.usbserial-DA01HLQC", open="r") | |
data <- data.frame(scan(f, n=60, what = "double", allowEscapes = TRUE, sep = "\n")) | |
close(f) | |
colnames(data) <- "all_data" | |
parsed_data <- separate(data, all_data, | |
c("voltage_t", |
This file contains hidden or 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
test <- as.character(c(1,1,1,0,0,1,1,1,1,0,1,1,1,1,0,0,0,0,1,1,1)) | |
test_rle <- rle(test) | |
unique_lengths <- make.unique(as.character(test_rle$lengths)) | |
data.frame(unique_lengths,test_rle$lengths) | |
group_labels <- rep(unique_lengths, test_rle$lengths) | |
data.frame(test,group_labels) |