Skip to content

Instantly share code, notes, and snippets.

View hurrialice's full-sized avatar
🌷

Qing Zhang hurrialice

🌷
View GitHub Profile
@jaymecd
jaymecd / a_json_data_pivot_with_jq.md
Created June 2, 2020 11:57
This JQ one-liner to pivot JSON data

Pivot JSON data

This one-liner pivots data from group>users or user>groups:

$ cat incoming.json \
  | jq 'map(. as $in | .users[] | . as $u | {user:$u, group:$in.group}) | group_by(.user) | map({user:.[0].user, groups: map(.group)})'

[
 {
@hurrialice
hurrialice / batch_igv.py
Last active March 30, 2020 14:02
Run IGV with a list of locations and with GDC api
import igv_remote as ir
import keyboard
import numpy as np
import pandas as pd
cohort = "BRCA"
print("cohort: {}".format(cohort))
# generate localhost http format
def format(uuid):
return("http://localhost:5000/" + uuid + ".bam")
@hurrialice
hurrialice / record_logs.R
Created November 10, 2019 03:55
allow better formatting display of messages, store all communications as list for programmatically access
#' better display and logging backend
#'
#' @param expr expression to evalutate
#' @param tag_width The width of display box of the message tag
#' @param path where the message goes, default to `stdout()`
#' @param save_conditions if `TRUE`, all conditions will be saved to a list
#' @param quiet if `TRUE`, all messages (error excluded) will be suppressed
#' @examples
#' test_function <- function(){
@elowy01
elowy01 / BCFtools cheat sheet
Last active August 22, 2025 14:46
BCFtools cheat sheet
*bcftools filter
*Filter variants per region (in this example, print out only variants mapped to chr1 and chr2)
qbcftools filter -r1,2 ALL.chip.omni_broad_sanger_combined.20140818.snps.genotypes.hg38.vcf.gz
*printing out info for only 2 samples:
bcftools view -s NA20818,NA20819 filename.vcf.gz
*printing stats only for variants passing the filter:
bcftools view -f PASS filename.vcf.gz
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active October 28, 2025 08:20
set -e, -u, -o, -x pipefail explanation
@aklap
aklap / fix-missing-libcrypto-osx.md
Created October 17, 2016 04:25
Resolving missing link to libcrypto/openssl on OSX
@olih
olih / jq-cheetsheet.md
Last active October 28, 2025 07:54
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@joar
joar / jq-insert-var.sh
Last active July 24, 2025 14:46
Add a field to an object with JQ
# Add field
echo '{"hello": "world"}' | jq --arg foo bar '. + {foo: $foo}'
# {
# "hello": "world",
# "foo": "bar"
# }
# Override field value
echo '{"hello": "world"}' | jq --arg foo bar '. + {hello: $foo}'
{
@ajaegers
ajaegers / git-move-files-in-subfolder.md
Last active August 25, 2025 09:51
Git: move files in an subfolder keeping history

Change structure of project folder with Git

I have this structure:

 project-folder/
     .git
     wp-admin/
     wp-content/
     wp-includes/

.htaccess

@benmarwick
benmarwick / captions_and_crossrefs.rmd
Last active March 24, 2023 17:53
Auto-numbering and cross-referencing of figures and tables in rmarkdown
---
title: "Auto-numbering and cross-referencing of figures and tables in rmarkdown"
output: html_document
---
NOTE: I recommend using the bookdown package and `output: html_document2` to make captions and cross-references more easily than the method described below.
TODO: check this out: https://github.com/adletaw/captioner
Here's how to use: