Skip to content

Instantly share code, notes, and snippets.

@kevinmhadi
kevinmhadi / Rprofile.R
Last active September 4, 2025 16:02
R Sources
# options(stringsAsFactors = FALSE)
# options(bitmapType="cairo")
# options(device = grDevices::png)
# options(scipen = 0)
Sys.setenv(R_DATATABLE_NUM_THREADS = 1)
Sys.setenv(R_REMOTES_UPGRADE = "never")
Sys.setenv(R_REMOTES_NO_ERRORS_FROM_WARNINGS = "true")
Sys.setenv("GENCODE_DIR" = "~/DB/GENCODE")
merged_inputs = filtered_ffpe_impact_somatic_vcf_inputs // patient, meta, annotated somatic_mut_vcf
.cross(sbs_posterior_prob_join) { v -> v[0] } // patient, sbs_posterior_prob
.map { it[0] + it[1][1..-1] } // remove patient key from 2nd tuple
.cross(indel_posterior_prob_join) { v -> v[0] } // patient, indel_posterior_prob
.map { it[0] + it[1][1..-1] } // remove patient key from 2nd tuple
.map { it -> [it[1], it[2], it[3], it[4] ] } // meta, annotated somatic_mut_vcf, sbs_posterior_prob, indel_posterior_prob
@kevinmhadi
kevinmhadi / mamba.sh
Created April 10, 2025 16:14
Installing mskilab dependencies through mamba/conda
mamba install --yes samtools vcftools bcftools htslib tabix pandas numpy pysam cyvcf2 r-data.table bioconductor-s4vectors bioconductor-genomicranges r-jsonlite bioconductor-variantannotation bioconductor-biostrings r-magrittr r-rcpp r-igraph r-ggplot2 r-plotly r-devtools r-htmlwidgets r-stringr r-gplots r-hwriter r-optparse bioconductor-complexheatmap r-arrow ensembl-vep requests urllib3 kiwisolver idna charset-normalizer certifi parallel openjdk nodejs r-seqminer r-ggextra r-ggpubr
@kevinmhadi
kevinmhadi / ssh_setup.md
Last active March 25, 2025 22:08
VSCode Help

Using remote SSH is a bit tricky with specific HPC setups. What I've had to do is set up my ~/.ssh/config file on my local mac with the following config with the RemoteCommand flag to instantiate a specific environment on the remote server:

Host *
    ControlMaster no
    # ControlMaster auto
    # ControlPath ~/.ssh/smux/ssh_mux_%C
    # ControlPersist yes
    Compression no
    ExitOnForwardFailure yes
@kevinmhadi
kevinmhadi / Rprofile.R
Created February 19, 2025 15:50
R sources
# options(stringsAsFactors = FALSE)
# options(bitmapType="cairo")
# options(device = grDevices::png)
# options(scipen = 0)
Sys.setenv(R_DATATABLE_NUM_THREADS = 1)
Sys.setenv(R_REMOTES_UPGRADE = "never")
Sys.setenv(R_REMOTES_NO_ERRORS_FROM_WARNINGS = "true")
Sys.setenv("GENCODE_DIR" = "~/DB/GENCODE")
@kevinmhadi
kevinmhadi / bash_functions.sh
Last active August 14, 2025 13:57
bash functions
set -a
get_timestamp() {
timestamp=$(date '+%Y-%m-%d-%H-%M-%S')
echo "$timestamp"
}
append_timestamp() {
echo "___$(get_timestamp)"
}
@kevinmhadi
kevinmhadi / nb_conda_kernel_R_setup.md
Last active July 25, 2025 01:25
Install R kernels to separate nb_conda_kernel environment

Below is a template to install R Kernels to a separate nb_conda_kernel environment.
In a terminal run the below commands:

. ~/scripts/load_miniforge # or source ~/scripts/load_miniforge, . and source do the same thing
conda activate jupyter_main # jupyter with nb_conda_kernel
export jupyter_=$(which 'jupyter')
jupyter () { ${jupyter_} $@; } # refers to the jupyter install of 
export -f jupyter
export rkernel_prefix=${CONDA_PREFIX} # refers to the conda environment of `jupyter_main`
@kevinmhadi
kevinmhadi / screens.sh
Last active July 25, 2025 01:25
Copy paste screen commands ()
# RANDOM=000
## Set this variable to name your screens
N=kevin
export mymktemp=$(which "mktemp")
export tmpdir___temp=${HOME}/SCREENTMPDIR
mkdir -p ${tmpdir___temp}
mktemp() {
local TMPDIR=${tmpdir___temp}
(export TMPDIR && ${mymktemp} $@)
@kevinmhadi
kevinmhadi / 000_shell_utils.sh
Last active July 22, 2025 16:22
Shell Utilities
path_append () { path_remove $1; export PATH="$PATH:$1"; }
path_prepend () { path_remove $1; export PATH="$1:$PATH"; }
path_remove () { export PATH=`echo -n $PATH | awk -v RS=: -v ORS=: '$0 != "'$1'"' | sed 's/:$//'`; }
@kevinmhadi
kevinmhadi / sshchmod.sh
Created October 21, 2024 15:04
Permissions for passwordless SSH
#!/bin/bash -e
chmod u=rwx,g=rxs,o=rx ~/
chmod u=rwx,go= ~/.ssh
chmod u=rw,go= ~/.ssh/authorized_keys