Skip to content

Instantly share code, notes, and snippets.

View thanhleviet's full-sized avatar
🤗
Focusing

Thanh Lee thanhleviet

🤗
Focusing
View GitHub Profile
@thanhleviet
thanhleviet / gen_samples.py
Created February 7, 2020 11:23
Gen SampleSheet for irida
#!/usr/bin/env python3
# Author: thanh le viet 12-2019
import pathlib
import click
import re
@click.command()
@click.option('--pid', default='', help='Project ID')
@thanhleviet
thanhleviet / nanopore.sh
Last active February 5, 2020 11:09
Install basic nanopore software
#Install MinKNOW
sudo apt-get update
sudo apt-get install wget
wget -O- https://mirror.oxfordnanoportal.com/apt/ont-repo.pub | sudo apt-key add -
echo "deb http://mirror.oxfordnanoportal.com/apt bionic-stable non-free" | sudo tee /etc/apt/sources.list.d/nanoporetech.sources.list
sudo apt-get update
sudo apt-get install minion-nc
#Install Guppy
@thanhleviet
thanhleviet / id_rsa.pub
Created February 1, 2020 13:27
macbook public key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDShCb7OtE+KTv4JWrKzLYZ1Nyul4eppxIRYUCxGdEIGe4Q68m+LR1ZofnojgIrMKV5VGeWv1OUAteHkBC396AMB/bDK7bvHDeN43egiameTlvRXbW7qpnpL+6XkLMOokP9wmMqFE2TVnQstG56LpZfKgVlYQpk9oksxqyUr3jMvA5VSdz191jtEv2KhdZUYELo7thZ6nPTtqYmk2JGuOumekm5l+tRENop6Al3ez09oGAnzJmh9v09o9BPkRXDIwyMN9D1q/Na7SUpe1RrfT1dQY9+YVp7XhPPI+GIcNzMif91xgqt0sMXU+65e3HPjz+feaeWAr966tV+0j5Na1br thanhlv@LVBH
@thanhleviet
thanhleviet / download.r
Created July 29, 2019 14:43
Read a tabular file including 2 columns: ID and URLs, scan urls to read files for each ID, generate a bash file to download the scanned URLs using ascp
library(readxl)
library(readr)
library(dplyr)
library(stringr)
library(glue)
setwd("~/Documents/bioinformatics/")
ids <- read_excel("NCTC_pacbio.xlsx", col_names = c("strains", "run_acc")) %>%
mutate(run_acc = gsub("https://www.ebi.ac.uk/ena/data/view/", "", run_acc)) %>%
mutate(run_acc_url = glue("https://www.ebi.ac.uk/ena/data/warehouse/filereport?accession={run_acc}&result=read_run&fields=run_accession,submitted_ftp,submitted_md5"))
@thanhleviet
thanhleviet / plot_depth.r
Created June 12, 2019 22:40
Plot depth cov for dengue genome
library(readr)
library(dplyr)
add.alpha <- function(col, alpha=1){
if(missing(col))
stop("Please provide a vector of colours.")
apply(sapply(col, col2rgb)/255, 2,
function(x)
rgb(x[1], x[2], x[3], alpha=alpha))
}
library(RSelenium)
library(dplyr)
library(rvest)
library(tibble)
#add url
url <- "https://www.toimitilat.fi/toimitilahaku/?size_min=&size_max=&deal_type%5B%5D=1&language=fin&result_type=list&advanced=0&gbl=1&ref=main#searchresult"
# docker run -d -p 4445:4444 selenium/standalone-firefox:2.53.1
remDr <- remoteDriver(
remoteServerAddr = "127.0.0.1",
@thanhleviet
thanhleviet / kraken2.nf
Created January 21, 2019 12:14
Kraken2 + Bracken
#!/usr/bin/env nextflow
params.pattern = "*_L001_R{1,2}_001.fastq.gz"
params.input = "/hpc-home/leviet/data/gonococci/July13"
params.output = "/hpc-home/leviet/data/gonococci_result_July13"
params.readlen = 150
params.db = "/qib/platforms/Informatics/databases/kraken2/kraken2_db_20190110"
params.bracken_kmer = "/qib/platforms/Informatics/databases/bracken/database150mers.kmer_distrib"
params.tax_level = "S"
threads = 8
@thanhleviet
thanhleviet / bamfilter_oneliners.md
Created August 4, 2018 15:37 — forked from davfre/bamfilter_oneliners.md
SAM and BAM filtering oneliners
@thanhleviet
thanhleviet / tree_ape.r
Last active August 1, 2018 04:22
See tips from a tree
library(ape)
tree <- rtree(n = 20)
plot(tree, edge.width = 2)
#By default, tips odered from bottom to top
t <- tree$tip.label
# Re order from top to bottom
rev(tree$tip.label)
#Write out to a text file
sapply(t, function(x) write(x,"tips.txt", append = T))
@thanhleviet
thanhleviet / subset_multiple_conditions.r
Created May 17, 2018 12:05
Subset with multiple conditions
mtcars %>%
mutate(
selected = case_when(
cyl == 6 & carb == 4 ~ "yes",
cyl == 8 & carb == 8 ~ "yes",
TRUE ~ "no"
)
) %>%
filter(selected == "yes") %>%
select(-selected)