Skip to content

Instantly share code, notes, and snippets.

RUN apt-get update && apt-get install -y \
xz-utils \
build-essential \
&& rm -rf /var/lib/apt/lists/* \
&& curl -SL https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz \
| tar -xJC . && \
mv clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04 clang_10.0.0 && \
echo 'export PATH=/clang_10.0.0/bin:$PATH' >> ~/.bashrc && \
echo 'export LD_LIBRARY_PATH=/clang_10.0.0/lib:$LD_LIBRARY_PATH' >> ~/.bashrc
@naarkhoo
naarkhoo / dot_plot
Created September 7, 2020 09:54
dot plot - a simple way to visualize numeric value in high dimensional data
library(ggplot2)
# library(patchwork)
mtcars$car_name <- rownames(mtcars) # create new column for car names
# arrange data set in order of mpg
mtcars$car_name <- factor(mtcars$car_name, levels = mtcars$car_name[order(mtcars$mpg)])
mtcars$car_name
p1 <- ggplot(mtcars, aes(x=car_name, y=mpg)) +
@naarkhoo
naarkhoo / histogram
Created December 17, 2019 08:48
Dash plotly - interactive histogram with fitted line on top with a slider
import plotly.graph_objs as go
import plotly.figure_factory as ff
import numpy as np
data = [30.2049, 51.3693, 51.8094, 30.5573, 56.8151, 45.9166, 56.2858, 55.4125, 72.8778,
39.7996, 34.8203, 36.8362, 39.9959, 54.7995, 52.5158, 40.6841, 61.3939, 48.5818,
41.4944, 71.5607, 49.0913, 57.7985, 70.2787, 45.2226, 55.7449, 69.0475, 33.9624,
51.3384, 53.1948, 46.1682, 66.5202, 37.0265, 48.0182, 44.2164, 56.9336, 69.7961,
48.6728, 44.5923, 33.2164, 41.8337,56.7741, 35.6030, 33.9237, 41.5178, 50.4453,

Keybase proof

I hereby claim:

  • I am naarkhoo on github.
  • I am mangul (https://keybase.io/mangul) on keybase.
  • I have a public key ASCCxl64gmHg-uhZGp6OOXhn6FgrikjR5VUG--YPoND-KQo

To claim this, I am signing this object:

@naarkhoo
naarkhoo / trim_audio.py
Last active July 2, 2023 17:01
trim audio via python
from pydub import AudioSegment
AUDIO_FILE = '/Users/alireza/Devel/Alaki/aeneas/test_farsi/13980218_27113_128k.mp3'
sound = AudioSegment.from_file(AUDIO_FILE)
p1 = sound[2039*1000: 2049.1*1000]
p1.export('/Users/alireza/Devel/Alaki/Goharbar/DarsKhandan2.mp3', format='mp3')
@naarkhoo
naarkhoo / ggplot2 color
Created May 26, 2017 11:52
Get color codes of a ggplot figure
ggplotColours <- function(n = 6, h = c(0, 360) + 15){
if ((diff(h) %% 360) < 1) h[2] <- h[2] - 360/n
hcl(h = (seq(h[1], h[2], length = n)), c = 100, l = 65)
}
ggplotColours(n = 3)
@naarkhoo
naarkhoo / gist:9e43cc418cc70522dd8d
Last active September 7, 2020 09:56
make a phyloseq object from a csv
biom convert -i phylum_for_biom2.csv -o tmp.biome --table-type="otu table" # first convert the csv to biom
biom_file = "rawfiles/genus.biome"
biomot_pair = import_biom(BIOMfilename=biom_file)
TAX = matrix(rownames(otu_table(biomot_pair))) #rownames are taxa names !
rownames(TAX) = as.matrix(TAX)
map_tab = read.table("rawfiles/phenotypes_GB.tsv", sep = "\t", header = T)
physeq.genus = phyloseq(otu_table(biomot_pair), tax_table(TAX), sample_data(pheno_tab));
@naarkhoo
naarkhoo / gist:25dc9da1ddc474bec624
Last active August 29, 2015 14:19
Pipeline to process V3+V4 16sRNA from MiSeq
# do this on each sample
#usearch -fastq_filter raw.fq -fastqout reads.fq -fastq_trunclen 260 -fastq_truncqual 10 -fastq_maxee 0.5
rawdir="/home/rostam/Projects/16srna/MS96/raw_data/"
maindir="/home/rostam/Projects/16srna/MS96/Mature"
output_dir=$maindir/"R260/pair/intereads/"
#tools
usearch61="/bin/usearch61"
flash="/home/rostam/qiime_software/smash-v2.0/flash/flash"
@naarkhoo
naarkhoo / kmeans
Created September 3, 2013 15:20
kmeans algorithm in R
km_dists = function(distm, K, nstart=10, maxiter=100) {
# initializations :
n = nrow(distm)
clusts = as.list(rep(0,K))
bestClusts = 0 ; bestDistor = 0.0
for (repet in 1:nstart) {
ctrs = sort(sample(1:n,K)) # centers initialization randomly
oldCtrs = rep(0,K)
counter = 1