Last active
April 25, 2018 14:22
-
-
Save DSuveges/5771f3a8fd44e4713c3fbdf284f9c741 to your computer and use it in GitHub Desktop.
In this gist I'm collecting all those 'crazy' bash snippets that might be useful in the future, or have some other reason to get remember of.
This file contains 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
# Get overlapping protein-coding genes for a set of rsIDs: | |
variants="rs6796106 | |
rs191957455 | |
rs41264153 | |
rs145265828" | |
# This script loops through a set of variants and returns the overlapping gene(s): | |
for v in $variants ; do wget -q http://ec2-54-91-140-228.compute-1.amazonaws.com:5000/variation/human/${v}.json -O - | jq -r '"\(.name) \(.mappings[0].location)"'; done | while read rsID location; do genes=$(wget -q "http://ec2-54-91-140-228.compute-1.amazonaws.com:5000/overlap/region/human/${location}?feature=gene&content-type=application/json" -O - | jq -r '[ .[] | select(.biotype == "protein_coding").external_name ] | join(",")') ; echo $rsID $genes; done | |
# This script looks up a variant in the eQTL database (through the Ensembl REST API), and returns all the genes in which the p-value was lower than1e-9 (Also returns the gene names as well from a separate REST query) | |
variant="rs2736340" | |
cat <(echo "GeneName GeneID Cell_type -log(pvalue)") <(wget -q "http://ec2-54-91-140-228.compute-1.amazonaws.com:5000/eqtl/variant_name/homo_sapiens/${variant}?content-type=application/json;statistic=p-value" -O - | jq -r '.[] | select ( .minus_log10_p_value > 9) | "\(.gene) \(.tissue) \(.minus_log10_p_value)"' | sort -k3,3nr| while read geneID tissue pval; do gene_name=$(wget -q --header='Content-type:application/json' "http://ec2-54-91-140-228.compute-1.amazonaws.com:5000/lookup/id/${geneID}" -O - | jq -r '.display_name'); echo ${gene_name:--} $geneID $tissue $pval;done) | column -t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment