Skip to content

Instantly share code, notes, and snippets.

View elowy01's full-sized avatar

Ernesto Lowy elowy01

  • Biofidelity
  • Cambridge, UK
View GitHub Profile
# general scatter plot
sns.scatterplot(data=ag1_df, x="ivaf", y="ovaf")
1) Click on file in the repo
2) Click on the icon: 'Copy raw contents'
import pdb
all_ids = set()
def parse_ids(ifile: str):
"""Parse ids from list. Ids are in first column"""
info_d = dict()
with open(ifile) as ifile1:
for line in ifile1:
line = line.rstrip("\n");
if line.startswith("#"): continue
import matplotlib.pyplot as plt
from matplotlib_venn import venn2
# Use the venn2 function
venn2(subsets = (10, 5, 2), set_labels = ('Group A', 'Group B'))
plt.show()
# Good post at:
https://www.biostars.org/p/84686/
// params defaults
params.help = false
params.cpus = 1
params.C = 'true'
def helpMessage() {
log.info"""
Pipeline to align FASTQ file/s to a reference file
--------------------------------------------------
Usage:
# Extracted from : https://medium.com/analytics-vidhya/pandas-how-to-change-value-based-on-condition-fc8ee38ba529
import pandas as pd
import numpy as np
data = {'Stock': ['AAPL', 'IBM', 'MSFT', 'WMT'],
'Price': [144.8, 141.61, 304.21, 139.5],
'PE': [25, 21, 39, 16],
'TradingExchange': ['NASDAQ', 'NYSE', 'NASDAQ', 'NYSE']}
df = pd.DataFrame(data)
# merge
bedtools merge -i ifile.bed -c 4 -o collapse # print the merged feature names (4th column)
# intersect
$ cat A.bed
chr1 10 20
chr1 30 40
$ cat B.bed
chr1 15 20
from nucleus.io import vcf
from nucleus.util import variant_utils
with vcf.VcfReader('/home/ec2-user/DEEPVARIANT/NA12878_calls.vcf.gz') as reader:
print('Sample names in VCF: ', ' '.join(reader.header.sample_names))
for variant in reader:
print(variant_utils.variant_type(variant)) # variant type
print(variant.reference_name) # reference
import keras
import pdb
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout
from keras.optimizers import RMSprop
import numpy as np
# Load mnist data
(x_train, y_train), (x_test, y_test) = mnist.load_data()