Guest User

Untitled

a guest
Jul 22nd, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. library(RMySQL)
  2. library(RColorBrewer)
  3. library(MASS)
  4. mypalette<-c(brewer.pal(8,"Blues")[8:1],brewer.pal(8,"Greens"))
  5. con <- dbConnect(MySQL(), user="user", password="password", dbname= "pride", host = "localhost", port = 4057)
  6. query1 = "select p.name, p.cv_label, p.accession, count(distinct(e.accession)), cast(group_concat(distinct(e.experiment_id) order by 1) as char)
  7. from mzdata_param as p, pride_experiment as e, mzdata_mz_data mz
  8. where mz.mz_data_id= e.mz_data_id
  9. AND p.parent_element_fk=mz.mz_data_id
  10. and p.param_type=5
  11. and cv_label='NEWT'
  12. group by p.name
  13. order by 1"
  14. dataM = dbGetQuery(con, query1)
  15. dbDisconnect(con)
  16.  
  17. species = dataM[,1]
  18. identVec = vector()
  19. pepVec = vector()
  20. specVec = vector()
  21. for(i in 1:length(species)){
  22. con1 <- dbConnect(MySQL(), user="user", password="password", dbname= "pride", host = "localhost", port = 4057)
  23. experimentList = dataM[i,5]
  24. identificationsQ = paste("select count(identification_id) from pride_identification
  25. where experiment_id IN ('",experimentList,"')", sep = "")
  26. identCount =dbGetQuery(con1, identificationsQ)
  27. peptidesQ = paste("select count(peptide_id)
  28. from pride_identification i, pride_peptide p
  29. where i.identification_id = p.identification_id
  30. and i.experiment_id IN ('",experimentList,"')", sep = "")
  31. pepCount = dbGetQuery(con1, peptidesQ)
  32. specQ = paste("select count(*)
  33. from mzdata_spectrum as s, mzdata_mz_data as m, pride_experiment as e
  34. where s.mz_data_id=m.mz_data_id
  35. and m.accession_number = e.accession
  36. and e.experiment_id IN ('",experimentList,"')", sep = "")
  37. specCount = dbGetQuery(con1,specQ)
  38. dbDisconnect(con1)
  39. pepVec = append(pepVec,as.numeric(pepCount), after = length(pepVec))
  40. identVec = append(identVec,as.numeric(identCount), after = length(identVec))
  41. specVec = append(specVec,as.numeric(specCount), after = length(specVec))
  42. }
  43.  
  44. dataM = cbind(dataM, pepVec)
  45. dataM = cbind(dataM, identVec)
  46. dataM = cbind(dataM, specVec)
  47. write.matrix(dataM,"C:\\Documents and Settings\\joe\\My Documents\\MOReview\\MOdata_withSpecies.csv", sep = "\t")
  48. # need to correalte species with kingdoms
  49. # need to correlate model organisms or not
Add Comment
Please, Sign In to add comment