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
| #!/usr/bin/Rscript | |
| library('SKAT') | |
| cat("WARNING: this script doesn't perform a sanity check on your data and therefore it's your own responsibility to provide correct input data.\n") | |
| args = unlist(strsplit(commandArgs(trailingOnly = TRUE)," ")) | |
| basename = strsplit(basename(args), "\\.")[[1]][1] | |
| dat <- read.table(args[1], header=TRUE, stringsAsFactors=FALSE) | |
| phen = ifelse(dat$PHENOTYPE == 2, 0, 1) #Convert affected = 2 to affected = 0 | |
| geno = as.matrix(dat[,-c(1:6)]) |
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
| genderPlots <- function(genders, counts, samples) { | |
| # Making orthogonal gender-specific plot based on genes from https://www.ncbi.nlm.nih.gov/pubmed/23829492 | |
| # coloured by expected gender (genders vector) | |
| # adding labels based on sample names (samples vector) | |
| maleGenes <- c('ENSG00000129824', 'ENSG00000198692', 'ENSG00000067048', 'ENSG00000012817') | |
| femaleGenes <- c('ENSG00000229807') | |
| if (any(maleGenes %in% rownames(counts))){ | |
| maleCounts <- (rowSums(t(counts[rownames(counts) %in% maleGenes,])) / colSums(counts)) * 1000000 | |
| } else { | |
| maleCounts <- rep(0, length(genders)) |
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
| genderPlots <- function(genders, counts, samples) { | |
| # Making orthogonal gender-specific plot based on genes from https://www.ncbi.nlm.nih.gov/pubmed/23829492 | |
| maleGenes <- c('ENSG00000129824', 'ENSG00000198692', 'ENSG00000067048', 'ENSG00000012817') | |
| femaleGenes <- c('ENSG00000229807') | |
| if (any(maleGenes %in% rownames(counts))){ | |
| maleCounts <- rowSums(t(counts[rownames(counts) %in% maleGenes,])) | |
| } else { | |
| maleCounts <- rep(0, length(genders)) | |
| } | |
| if (any(femaleGenes %in% rownames(counts))){ |
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
| # wdecoster | |
| import sys | |
| import pysam | |
| import os | |
| import concurrent.futures as cfutures | |
| import glob | |
| import matplotlib.pyplot as plt | |
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
| """ | |
| Modified and extended from https://stackoverflow.com/q/7479442/6631639 | |
| """ | |
| from os import urandom | |
| import random | |
| import string | |
| import pyperclip | |
| from argparse import ArgumentParser |
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
| # wdecoster | |
| """ | |
| Reads from stdin, writes to stdout. | |
| """ | |
| from __future__ import print_function | |
| from Bio import SeqIO | |
| from argparse import ArgumentParser | |
| import sys |
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
| """ | |
| based on https://neuroscience.telenczuk.pl/?p=331 | |
| """ | |
| import svgutils.transform as sg | |
| class Svg(object): | |
| "svg files with a data object (the svg), width, height and coordinates" |
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
| """ | |
| based on: | |
| https://stackoverflow.com/a/451580/6631639 | |
| https://kanoki.org/2017/07/12/merge-images-with-python/ | |
| https://stackoverflow.com/a/16377244/6631639 | |
| https://stackoverflow.com/a/41887497/6631639 | |
| """ | |
| import numpy as np | |
| from PIL import Image, ImageFont, ImageDraw |
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
| from Bio import SeqIO | |
| import sys | |
| def codonize(seq): | |
| """Split a string in codons per 3 characters.""" | |
| return [seq[i:i + 3] for i in range(0, len(seq), 3)] | |
| def check_codon(fasta, codon="TTA"): |
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
| def stream_fastq_full(fastq, threads): | |
| ''' | |
| Extract from a fastq file: | |
| -readname | |
| -average and median quality | |
| -read_lenght | |
| ''' | |
| with cfutures.ThreadPoolExecutor(max_workers=threads) as executor: | |
| for results in executor.map(extract_all_from_fastq, SeqIO.parse(fastq, "fastq")): | |
| yield results |