Skip to content

Instantly share code, notes, and snippets.

View cplaisier's full-sized avatar

Christopher L Plaisier, PhD cplaisier

View GitHub Profile
# Load counts
d0 = read.csv('gexp_counts.csv',header=T,row.names=1)
d0 = d0[which(apply(d0,1,sum)!=0),]
library(DESeq2)
conds = data.frame(subset=factor(c(rep('Cntl_CD44Low',4), rep('Cntl_Ag85B_Plus_PD1_Plus',4), rep('Cntl_ESAT6_Plus_PD1_Plus',4), rep('Stim_Ag85B_Plus_PD1_Plus',4), rep('Stim_ESAT6_Plus_PD1_Plus',4))))
rownames(conds) = colnames(d0)
# Make a map of Entrez IDs to UCSC transcript IDs
d1 = read.csv('entrez2ucsc.csv',header=F)
entrez2ucsc = list()
@cplaisier
cplaisier / cmonkey_setEnrichment.ini
Last active February 23, 2016 22:47
For set enrichment run.
[General]
num_iterations = 2000
num_clusters = 133
normalize_ratios = False
num_cores = 6
checkpoint_interval = 100
stats_frequency = 50
result_frequency = 50
[SetEnrichment]
@cplaisier
cplaisier / Coefficient of Determination
Last active November 7, 2017 20:35
Code to compute coefficient of determination
from itertools import imap
import operator
import logicFuncs as lf
def mean_squared_error(r1, p1):
#assert len(r1) == len(p1)
return sum([(float(p1[i])-float(r1[i]))**2 for i in range(len(r1))])/float(len(r1))
def hammingDist(str1, str2):
assert len(str1) == len(str2)
@cplaisier
cplaisier / loadingJSON.py
Created March 6, 2018 15:22
Loading the TFBSDB JSON file.
# Loading JSON file
# https://www.safaribooksonline.com/library/view/python-cookbook-3rd/9781449357337/ch06s02.html
# Example:
# import json
#
# # Reading data back
# with open('data.json', 'r') as f:
# data = json.load(f)
import json
motifName2entrezId = {}
entrezId2motifName = {}
# humanTFs_All.csv with columns separated by commas - Motif Name,Gene Symbol,Entrez ID
with open('id_conversion/humanTFs_All.csv','r') as inFile:
header = inFile.readline().strip().split(',') # Capture header, get rid of white space ".strip()", and split by commas ".split(',')"
while 1:
inLine = inFile.readline()
#Breaks out of the while loop when we hit the end of the file
if not inLine:
break
@cplaisier
cplaisier / TF_TestNetwork.py
Last active March 13, 2018 18:19 — forked from ssstrike/TF_TestNetwork.py
Outputs list of associated Entrez ID to an input Entrez ID
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 12 18:16:24 2018
@author: Fuzzy
"""
import json
with open('tfbsDb_plus_and_minus_5000_entrez.json', 'r') as f:
data = json.load(f)
@cplaisier
cplaisier / TF_NetworkEntrez.py
Created March 20, 2018 17:31 — forked from ssstrike/TF_NetworkEntrez.py
takes an input Entrez ID and outputs a .sif file
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 12 18:16:24 2018
@author: Fuzzy
"""
import json
with open('tfbsDb_plus_and_minus_5000_entrez.json', 'r') as f:
data = json.load(f)
@cplaisier
cplaisier / geoParseExample.py
Created March 27, 2018 03:27
Example of use GEOParse
import GEOparse
import pandas as pd
import matplotlib.pyplot as plt
import numpy
from matplotlib.backends.backend_pdf import PdfPages
#gseNums = ['GSE14860']
#gseNums = ['GSE49278', 'GSE19750', 'GSE10846']
gseNums = ['GSE19417', 'GSE49278', 'GSE19750', 'GSE10846', 'GSE39582', 'GSE35158', 'GSE19422', 'GSE19987', 'GSE32894', 'GSE35158', 'GSE27155', 'GSE33630', 'GSE56303', 'GSE29695', 'GSE10141', 'GSE9843', 'GSE25097', 'GSE32225', 'GSE26566', 'GSE65858', 'GSE39366', 'GSE22138', 'GSE46517', 'GSE71729', 'GSE8607', 'GSE4573', 'GSE29354', 'GSE71118', 'GSE19949', 'GSE15641', 'GSE26253', 'GSE15460', 'GSE21034', 'GSE9891', 'GSE32062', 'GSE72094', 'GSE26939', 'GSE29174', 'GSE31448', 'GSE45725', 'GSE40435', 'GSE14860']
@cplaisier
cplaisier / TF_TestNetworkFam_3_27_2018.py
Last active March 27, 2018 17:56 — forked from ssstrike/TF_TestNetwork.py
input network list, dictionary, hops and output full .sif and sub .sif
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 24 12:19:38 2018
@author: Fuzzy
"""
import json
with open('tfbsDb_plus_and_minus_5000_entrez.json', 'r') as f:
data = json.load(f)
@cplaisier
cplaisier / entrezIDRedundancyRemoval.R
Last active March 29, 2018 16:02 — forked from oeltoham/Entrez Gene ID Mapping
Script to load up expression data and write out Entrez IDs
# Load libraries
library(GEOquery)
library(genefilter)
# Set working directory
setwd('C:/Users/cplaisie/Dropbox (ASU)/ASU/Students/Omar')
# Load up data
gset <- getGEO(filename="data/GSE26253_series_matrix.txt.gz", GSEMatrix=TRUE, AnnotGPL=T)
pData(gset)