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
# PROJECT_ID is the billable project code "word-word-number" | |
# Having -life-sciences suffix may be important | |
export BUCKET=gs://PROJECT_ID-life-sciences | |
# Make a bucket (storage folder) for input and output data | |
# See intro to installing gsutil in this gist https://gist.github.com/clairemcwhite/ca33c9b7385ee4e2b64641353399f3ba | |
gsutil mb ${BUCKET} | |
# First do the example script |
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
# This is extra instructions to access and query the hail tables from the pan ukbiobank | |
# https://pan.ukbb.broadinstitute.org/docs/hail-format/index.html | |
# | |
# Open a google cloud account, set up billing, get project id (word-word-number) | |
# Create a virtual machine | |
# Select Ubuntu 16.04 | |
# Allow access to all Cloud API (unknown if needed) | |
# Need python 3.7 for hail |
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
read_fasta <- function(fasta_filename, annot = FALSE){ | |
fasta <- seqinr::read.fasta(fasta_filename, as.string = TRUE) | |
# Convert seqinr SeqFastadna object to data.frame | |
fasta_df <- fasta %>% | |
sapply(function(x){x[1:length(x)]}) %>% | |
as.data.frame %>% | |
broom::fix_data_frame(newcol = "ID", newnames = "Sequence") | |
if(annot == TRUE){ |
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
# Only needed if using theme_cowplot. Otherwise, use any theme. | |
library(cowplot) | |
theme_cowplot_consistent_text <- function (font_size = 8) { | |
theme_cowplot() %+replace% | |
theme(strip.text = element_text(size = font_size), | |
axis.text = element_text(colour = "black", size = font_size), | |
plot.title = element_text(size = font_size), |
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) | |
get_order <- function(df, distmethod = "pearson", hclustmethod = "average", output_ordername = "order"){ | |
#Get the row ordering from a clustering | |
hr <- hclust(as.dist(1-cor(t(df), method=distmethod)), method=hclustmethod) | |
order <- data.frame(hr$labels[hr$order]) | |
order$ordering <- rownames(order) | |
names(order) <- c("ID", output_ordername) | |
return(order) | |
} |
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) # For everything | |
library(gganimate) # For animating graphs | |
library(ggraph) # For plotting graphs | |
library(magick) # For exporting gif | |
library(tidygraph) # For manipulating graphs | |
library(colorspace) # For sequential_hcl | |
library(igraph) # For random walk and as_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
library(tidygraph) | |
library(tidyverse) | |
library(ggraph) | |
library(dendextend) | |
library(igraph) | |
palette_OkabeIto <- c("#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7", "#999999") | |
cut_df <- function(dendrogram, height, c){ |