Monday, September 14, 2015

*** network aging simulation, net-aging-sim-2015Sep15.R


helen:ms02GINPPI hqin$ ll net-aging-sim-2014Sep*
-rw-r--r--  1 hqin  staff   4.2K Sep 14 18:37 net-aging-sim-2015Sep15.R
-rw-r--r--  1 hqin  staff   6.1K Sep 14 13:17 net-aging-sim-2015Sep7b.R


net-aging-sim-2015Sep15.R (aka net-aging-sim-20150915.R)
This script now takes argument for start and end ms02 networks, lambda, p and popSize
# R -f file --args start end lambda p popSize
#  R -f net-aging-sim-2014Sep15.R --args 1 1 0.002 0.95 10
# the network processing working inside of this work should be move outside of this script. 
# This script can iterate over ms02 networks with the same lambda, p, and popSize


#20150915Mon add argument for lambda, p, popSize

# 2014 Feb 17, change name "20131221.DIPandGIN.sim.aging_v2.R" to "net-aging-sim-2014Feb17.R"

# 2013 Dec 20, merge DIP PPI and Genetic Inxt Net -> Multi-net approach
rm(list=ls())

source("lifespan.r")
source("network.r")

#for debug
#  start =1; end = 1; lambda= 1/100; p = 0.95; popSize=5;


# R -f file --args start end lambda p popSize
#  R -f net-aging-sim-2014Sep15.R --args 1 1 0.002 0.95 10
options(echo=TRUE) # if you want see commands in output file
args <- commandArgs(trailingOnly = TRUE)
print(args)
# trailingOnly=TRUE means that only your arguments are returned, check:
# print(commandsArgs(trailingOnly=FALSE))
start = as.integer(args[1]); start; 
end = as.integer(args[2]); end; 
lambda = as.numeric(args[3]); lambda;
p = as.numeric(args[4]); p;
popSize = as.numeric(args[5]); popSize;


myhost = 'greenfield'  # 'byte' 'blacklight' 'mactower'
#myhost = 'byte'  # 'byte' 'blacklight' 'mactower'
myhost = 'helen';

mydir = "/crucible/mc48o9p/hqin2/mactower-network-failure-simulation-master/ms02GINPPI"
if (myhost == 'byte') {  mydir = "/Users/hqin/github/mactower-network-failure-simulation/ms02GINPPI"
} else if (myhost == 'helen') { mydir = "/Users/hqin/github/mactower-network-failure-simulation/ms02GINPPI";  

mydir
setwd(mydir)

debug = 0; 

#essential gene info
essenTb = read.csv('SummaryRegressionHetHom2013Oct29.csv', colClasses=rep('character', 9))


for ( i in start:end) {
  path = paste('dipgin.ms02.output/', i, sep='')
  ms02file = paste('ms02_', i, ".tab", sep='')
  infile = paste( path, '/', ms02file, sep=""); print(infile)
  pairs = read.table( infile, header=T, sep="\t", colClass = c("character", "character", NA) )
  print(head(pairs))
  if(debug==9) {     pairs = pairs[1:1000,]  }
  pairs = pairs[ pairs$id1 != pairs$id2, ]  

  # How do the two data set overlap? DIP seems to contain some questionable orfs
  uniq.orf.from.pairs = unique(c(pairs$id1, pairs$id2)) #5496 ORF
  matches = uniq.orf.from.pairs %in% unique(essenTb$orf)
  table(matches)
  
  # label essential nodes, remove nonesse-nonessen pairs
  essentialORFs = essenTb$orf[essenTb$essenflag=='essential']
  pairs$essen1 = pairs$id1 %in% essentialORFs
  pairs$essen2 = pairs$id2 %in% essentialORFs
  #remove nonessen <-> nonessen intxn because they do not affect aging. 
  pairs$remove = ifelse( pairs$essen1==F & pairs$essen2==F, T, F  )
  pairs= pairs[! pairs$remove, ]  
  # 34052 for one ms02 network
  
  #how many essen <--> essen intxn? 
  pairs$inxnEE = pairs$essen1 & pairs$essen2
  table(pairs$inxnEE)
  #How many essen genes? 
  tmp = essentialORFs %in% unique(c(pairs$id1, pairs$id2)) 
  table(tmp)
  essentialORFsPPI = essentialORFs[tmp] #?????
  
  #get connectivities per node
  degreeTb = data.frame( table(c(pairs[,1], pairs[,2])))
  summary(degreeTb)
  degreeTb$ORF = as.character( degreeTb[,1])
  
  degreeCutoff = 4; #######!!!!!! degree=5 is the median
  tmp = essentialORFsPPI %in% degreeTb$ORF[degreeTb$Freq>degreeCutoff]
  GooddEssentialORFsPPI = essentialORFsPPI[tmp]
    
  if(debug >= 5){GooddEssentialORFsPPI = GooddEssentialORFsPPI[1:100]  }
  
  sim_names = c( "degreeCutoff","p", "lambda", "meanLS", "medianLS", "R","G", "GompAIC", "WeibAIC")
  sim       = t( c(NA,     NA,   NA,       NA,       NA,        NA,  NA,   NA,      NA))
  sim = data.frame(sim)
  names(sim) = sim_names

  full_age_dir = paste(path, '/', 'popages', sep='')
  system(paste('mkdir ', full_age_dir ))
  
      popAges = numeric(popSize)
      time1 = date()
      j=1; count = 0; 
      while ((j <= popSize) && ( count < popSize*30)) {
        count = count + 1;      
        print(paste("count=",count))
        currentNetworkAge = single_network_failure(lambda, p, pairs, GooddEssentialORFsPPI)
        if (currentNetworkAge > 0) {
          popAges[j] = currentNetworkAge      
          j = j+1
        } 
      }# end of j while-loop, population loop
            
      
      timestamp = format(Sys.time(), "%Y%b%d_%H%M%S")
      age.file.name=paste("cutoff", degreeCutoff, "p", p, "lambda", lambda, 'popsize',popSize, "time",timestamp, "txt", sep="." )
      full_age_file = paste( full_age_dir,'/', age.file.name, sep='')
      
      write.csv( popAges, full_age_file, row.names=F)
        
}  

bio233 lab, 20150914 Monday

Preparation:
microscopy usage,
morphology, slides
bunsen burner, loops, 70% ethanol bottles, nutrient plates, paper towels
markers

2:10pm. Enough students trickled in. I wrote the tasks on board.
Show an video on microscope usage.

=> 1: take picture of environmental samples

=>Lab 2b: aseptic technique, streak colonies
Streaking plates was moved up
R rubrum is gram negative

Q: students asks why the loop have to be burned every time. 

=>3pm, Lab 2a: microscope usage, basic bacterial morphology

Ask students to take pictures using their smart phones.

finished by 3:30pm

Unfinished:
=> PPT and youtube video

Acorn, building 3D braining using 2D images

A student used Acron photo sofware, build 3D brain using multiple slides for neurobiology

bio233 surface to volume

sphere

ellipse, egg shape

rod
http://www.mathsteacher.com.au/year9/ch14_measurement/18_cylinder/cylinder.htm



Pubmed in R

https://gist.github.com/freshbiostats/2de46d0c7a59cbf54ad0

Thursday, September 10, 2015

bio233, 20150910Thu ch4, mole biol, part 1

Prep:
SPDB viewer to flash drives
HP laptops
Playdough for major grooves demo, right hand helix.

2:30-3pm, student draw central dogma. I showed my example to give students hints. I went over the slides during the drawing activity.
Problems:  Two students put start and stop codons to transcription.

10 minutes, SWISS PDB Viers on 5' and 3'end of DNA strand.
Problems: I forgot to tell the color code to the students. I save this by writing the code on the board.

30 minutes, playdoug on right handed DNA double helices.
Problems: 3 out of 8 groups made left-hand helices.

The class stopped at DNA double helices.

http://hongqinlab.blogspot.com/2014/03/bio233-ch6-dna-helices-bases-3d.html
http://hongqinlab.blogspot.com/2014/09/bio233-20140930-ch5-continued-and-ch6.html
http://hongqinlab.blogspot.com/2015/01/bio125-tue-jan-20-2015-dna-structure.html

Wednesday, September 9, 2015

FYE, time management/Grit

ML used Grit ted video by A Duckworth, and survey, followed by a PPT

====
bucket, stone, sand, water demo (using play dough)


procrastination


bio386, 20150910Thu

30 min: Review of aging questions

UTK meeting announcement again, abstract submission

Spent the rest of class on Coursera week 1 assignment.


Open but independent exam




emory network ID and password


https://login.emory.edu/idp/Authn/UserPassword


Emory network 404 727 7777.

I need 'epin' code to reset my password, because this is a sponsored account. Or, my sponsorship need to call the help desk to verify my identity.


(todo) Genetic evidence for common pathways in human age-related diseases


Genetic evidence for common pathways in human age-related diseases

http://onlinelibrary.wiley.com/doi/10.1111/acel.12362/suppinfo

  1. Johnson2015 Aging Cell

Table 2 show a list of gene on NCBI
One of the supplementary table listed a list of genes associated with longevity in a GWAS.
Only two genes overlap between these two list.

Todo:
1a) retrieve FASTA protein sequences of these human genes
1b) identify interacting partners of these human proteins, and retrieve their protein FASTA sequences
2) blast yeast genome to identify their homologs
3) any interesting phenotypes of the yeast mutants?

biological topics for computer science courses (in progress)

Coalescent simulation
Agent based simulation, infectious disease
Colony growth on agar plate
Gene networks. Graph model
phylogeny and evolutionary tree. Linked list
String: sequence analysis
OOP: genbank file, ORF, start and stop signals.
Arrays: genes and their lengths


Tuesday, September 8, 2015