Skip to content

Instantly share code, notes, and snippets.

@cmdcolin
cmdcolin / cpu.R
Last active April 19, 2024 00:34
visualization of dan luu website data https://genomic.social/@cmdcolin/112294679289295864
#!/usr/bin/env Rscript
library(reshape2)
library(ggplot2)
library(tidytext)
x <- read.csv("cpu.csv")
y <- melt(x)
colnames(y) <- c("site", "variable", "s")
y$s <- y$s / 1000
function TranscriptSelector() {
const [error, setError] = useState();
const [transcripts, setTranscripts] = useState();
const [selection, setSelection] = useState();
useEffect(() => {
async () => {
try {
const result = await loadTranscripts(); // imagine this just returned a list of strings
setTranscripts(result);
setSelection(result[0]); // set the initial selection to the first transcript
function MySelectBox() {
const opts = ["apple", "banana", "orange"];
const [mySelection, setMySelection] = useState("apple");
return (
<select
value={mySelection}
onChange={event => setMySelection(event.target.value)}
>
{opts.map(o => (
<option key={o} value={o}>
// this is a controlled component
function MyTextBox() {
const [myValue, setMyValue] = useState('initial value')
return <input type="text" value={myValue} onChange={event=>setMyValue(event.target.value)}/>
}
@cmdcolin
cmdcolin / gather_commits.js
Last active March 18, 2024 20:47
plot lines of code over time from a git repository
#!/usr/bin/env bash
## uses home directory to avoid git clean in repo clearing files
touch ~/lines
## choice 1. for all commits
git log --pretty=format:'%h %as'|sed 's/ /\t/' >! ~/commitlog
## choice 2. for all tags
git for-each-ref --sort=creatordate --format '%(refname) %(creatordate:short)' refs/tags|sed -e 's/refs\/tags\///'|sed 's/ /\t/' >! ~/commitlog
@cmdcolin
cmdcolin / gist:816da3899505c1e51f6da122ad7c90f5
Created March 15, 2024 20:49
ggplot2 vs css lch colors
testing
@cmdcolin
cmdcolin / convert_jbrowse_nclist_to_gff.ts
Created February 6, 2024 21:56
Convert JBrowse 1 NCList on disk to GFF
import { LocalFile } from 'generic-filehandle'
import NCList from '@gmod/nclist'
const filter = new Set([
'Start',
'End',
'Strand',
'Source',
'Seq_id',
'Name',
'Score',
// example code for "hand-drawing the d3-hierarchy on a canvas"
for (const { source, target } of hierarchy.links()) {
const { x: sy, y: sx } = source
const { x: ty, y: tx } = target
ctx.beginPath()
ctx.moveTo(sx, sy)
ctx.lineTo(sx, ty)
ctx.lineTo(tx, ty)
ctx.stroke()
#full google drive
#https://docs.google.com/spreadsheets/d/1ZpqZ3vVJ3ZIfdENLjeK0O7AYPewleSQ7ybT7DtotLK0/edit#gid=0
#this list slightly enriched for "weird names" by filtering out some not as interesting names using grep
#grep -v lncRNA|grep -v snoRNA|grep -v Su\(Ste\)|grep -v Male-specific|grep -v receptor|grep -v Zinc|grep -v antisense|grep -v ase|grep -v chain|grep -v factor|grep -v nuclear|grep -v loop|grep -v -i protein|grep -v RNA|grep -v Cell|grep -v Ste:|grep -v domain|grep -v Cytochrome|grep -v polypep|less|grep -v His
211000022279188:1449-2180 shortname=SteXh:CG42398 fullname=SteXh:CG42398
2L:10032690-10038954 shortname=obst-B fullname=obstructor-B
2L:10056900-10060095 shortname=Pen fullname=Pendulin
2L:10060816-10063925 shortname=Spn31A fullname=Serpin 31A
2L:10204757-10206961 shortname=Snx17 fullname=Sorting nexin 17
2L:10211143-10213721 shortname=ath fullname=athos
/* eslint-disable no-restricted-globals */
;(function () {
class UMDLocPlugin {
name = 'UMDLocPlugin'
version = '1.0'
install(pluginManager) {
/* do nothing */
}