Skip to content

Instantly share code, notes, and snippets.

View antonkratz's full-sized avatar

Anton Kratz antonkratz

View GitHub Profile
@antonkratz
antonkratz / PAGER.md
Created December 11, 2018 18:58
You might run into a situation where git log, man man display absolutely nothing.

You might run into a situation where git log, man man display absolutely nothing. This could be b/c bash forgot the PAGER variable. How this is possible is beyond me. You must reset the PAGER variable and then it will work again:

export PAGER=less
@antonkratz
antonkratz / ak.go.py
Last active December 28, 2018 00:53
Get BP, CC, MF and full GO in Clixo-style format
# author: Anton Kratz
# created: Mon Dec 17 19:08:48 PST 2018
# Based on original code by Mike Yu which is at [1]. However [1] has various NDEX and other
# code intermingled which is not necessary in this context. Also, I am building a similarity
# table for DNA repair on the fly.
# [1] https://github.com/michaelkyu/ddot/blob/master/examples/Process_the_Gene_Ontology.ipynb
import requests
@antonkratz
antonkratz / cytoscape_3.7.1_notes.md
Last active March 1, 2019 23:32
Cytoscape notes

Cytoscape 3.7.1

the layout is too dense and I want to expand the layout

Layout --> Node layout Tools --> Scale:

toolpanel

when I zoom out, the text on the label dissappears

@antonkratz
antonkratz / sed.md
Last active March 25, 2019 17:27
Delete lines in a text file that contain a specific string

Delete all lines in the file myfile that contain the string foobar:

sed -i '/foobar/d' myfile
@antonkratz
antonkratz / gist:eec1507d7efb77da25217af0638d1d01
Last active September 3, 2019 16:30
[a mighty AWK script] pull out the lines from the table which match a key from a list

file1: A list of keys, one key one line

file2: A table, the keys are in column 1

what this does: pull out the lines from the table which match a key from a list

time awk -F'      ' 'NR==FNR{c[$1]++;next};c[$1] > 0' file1 file2 > output.txt
@antonkratz
antonkratz / annoyance.md
Last active September 7, 2019 17:52
how to fix: conda adds an uncalled for `(base)` before my PS1 prompt
@antonkratz
antonkratz / gist:f3a7d8564044830be2d3ccf09fde199e
Created July 14, 2020 18:54
how to remove all clipping masks in Illu!
Select All
`Object > Clipping mask > Release`
`Object > Path > Clean up`
Clipping masks. Deleting an object deletes random objects scattered throughout b.c they are connected thru the clipping mask. I do not want this.
@antonkratz
antonkratz / getSmiles.py
Last active October 1, 2021 19:02
From drug NAME to SMILE string
import pubchempy as pcp
import pandas as pd
import numpy as np
from collections import OrderedDict
drugs_df = pd.read_csv('oli_drugs.csv')
def queryPubChem(compounds,batchlist = None,match='name'):
"""
This function queries the PubChem database to retrieve both the isomeric smile and CID of a compound.
@antonkratz
antonkratz / repelling_labels.r
Created August 17, 2021 23:14
Getting coordinates for the label locations from ggrepel, Cytoscape, https://stackoverflow.com/questions/45065567/getting-coordinates-for-the-label-locations-from-ggrepel, tested and works under R 4.1.1
x = c(0.8846, 1.1554, 0.9317, 0.9703, 0.9053, 0.9454, 1.0146, 0.9012, 0.9055, 1.3307)
y = c(0.9828, 1.0329, 0.931, 1.3794, 0.9273, 0.9605, 1.0259, 0.9542, 0.9717, 0.9357)
ShortSci = c("MotAlb", "PruMod", "EriRub", "LusMeg", "PhoOch", "PhoPho",
"SaxRub", "TurMer", "TurPil", "TurPhi")
df <- data.frame(x = x, y = y, z = ShortSci)
library(ggplot2)
library(ggrepel)
p1 <- ggplot(data = df, aes(x = x, y = y)) + theme_bw() +
geom_text_repel(aes(label = z),
@antonkratz
antonkratz / symlog_trans.R
Created May 31, 2022 18:14 — forked from davidtedfordholt/symlog_trans.R
A `scales`/`ggplot2` implementation of the `symlog` transformation
#' symlog transformation
#'
#' `symlog_trans()` transforms data using `log(x)` for `abs(x) > thr`, where
#' `thr` is a tuneable threshold, but leaves the data linear for `abs(x) < thr`.
#' (credit for base code to https://stackoverflow.com/users/1320535/julius-vainora)
#'
#'
#' @param base base of logarithm
#' @param thr numeric threshold for transitioning from log to linear
#' @param scale numeric scaling factor for data