Skip to content

Instantly share code, notes, and snippets.

View slavnycoder's full-sized avatar
🐘
💨

slavnycoder

🐘
💨
View GitHub Profile
@slavnycoder
slavnycoder / django-storage-walk.py
Last active May 19, 2020 12:35 — forked from btimby/django-storage-walk.py
os.walk() clone that uses Django storage object
import os
def storage_walk(storage, top='/'):
"""
List all files in django storage
"""
dirs, nondirs = storage.listdir(top)
for name in nondirs:
yield os.path.join(top, name)
# Plot differential gene expression venn diagram using python
# Example dataframe
# sample1 sample2 sample3
# gene1 1 0 1
# gene2 0 1 0
# gene3 -1 0 0
# gene4 0 0 -1
# gene5 0 1 0
from collections import defaultdict
@slavnycoder
slavnycoder / caching_dict.py
Last active June 25, 2021 23:31
Python caching dict. Have dict cache in file between runs.
class CachingDict:
def __init__(self, path):
self.path = path
if os.path.exists(self.path):
with open(self.path) as json_file:
self.data = json.load(json_file)
else:
self.data = dict()
self.dump()
import numpy as np
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt
def plot_volcano(data: pd.DataFrame, log2_fc_col: str, p_value_col: str, plot_title: str = "Volcano plot"):
"""
Plot volcano with seaborn
:param data: pandas DataFrame with your data
@slavnycoder
slavnycoder / plot_scatter_psr2.py
Last active February 3, 2022 15:42
Plot scatter with correlations
def plot_scatter_psr2(df: pd.DataFrame, x: str, y: str,
label_x: Optional[str] = None, label_y: Optional[str] = None,
title: str = None,
filename: str = None,
labels: List[str] = None
) -> None:
fig, ax = plt.subplots(figsize=(9, 6), dpi=200)
ax.scatter(df[x], df[y], marker="v", color="cornflowerblue")
a, b, r, p, err = scipy.stats.stats.linregress(df[x].values, df[y].values)
@slavnycoder
slavnycoder / ton_client.py
Last active April 26, 2024 10:00
TON http api python client
## API class for https://toncenter.com/
## requirements:
# tonsdk https://github.com/tonfactory/tonsdk/
# requests
# Donate (TON): EQCZG0qnpnNK2dCYoLCiLMCuP-QviaFvWiVDQja1vgMXn7uD
from typing import Optional, Literal, List, Coroutine
import aiohttp
import requests