comparison goprofiles.R @ 9:948fecb6a40b draft

planemo upload commit 973d782455fd6a7df7ba9bce0a7878de53bc1e68-dirty
author proteore
date Mon, 04 Mar 2019 05:48:48 -0500
parents 386145573c19
children 2138e0035e57
comparison
equal deleted inserted replaced
8:386145573c19 9:948fecb6a40b
77 # IDs that have NA ENTREZID 77 # IDs that have NA ENTREZID
78 NAs = id$UNIPROT[which(is.na(id$ENTREZID))] 78 NAs = id$UNIPROT[which(is.na(id$ENTREZID))]
79 #print("IDs unable to convert to ENTREZID: ") 79 #print("IDs unable to convert to ENTREZID: ")
80 #print(NAs) 80 #print(NAs)
81 } 81 }
82
83 # Create basic profiles 82 # Create basic profiles
84 profile.CC = basicProfile(genes_ids, onto='CC', level=level, orgPackage=species, empty.cats=F, ord=T, na.rm=T) 83 profile.CC = basicProfile(genes_ids, onto='CC', level=level, orgPackage=species, empty.cats=F, ord=T, na.rm=T)
85 profile.BP = basicProfile(genes_ids, onto='BP', level=level, orgPackage=species, empty.cats=F, ord=T, na.rm=T) 84 profile.BP = basicProfile(genes_ids, onto='BP', level=level, orgPackage=species, empty.cats=F, ord=T, na.rm=T)
86 profile.MF = basicProfile(genes_ids, onto='MF', level=level, orgPackage=species, empty.cats=F, ord=T, na.rm=T) 85 profile.MF = basicProfile(genes_ids, onto='MF', level=level, orgPackage=species, empty.cats=F, ord=T, na.rm=T)
87 profile.ALL = basicProfile(genes_ids, onto='ANY', level=level, orgPackage=species, empty.cats=F, ord=T, na.rm=T) 86 profile.ALL = basicProfile(genes_ids, onto='ANY', level=level, orgPackage=species, empty.cats=F, ord=T, na.rm=T)
88
89 # Print profile 87 # Print profile
90 # printProfiles(profile) 88 # printProfiles(profile)
91 89
92 return(c(profile.CC, profile.MF, profile.BP, profile.ALL)) 90 return(c(profile.CC, profile.MF, profile.BP, profile.ALL))
93 } 91 }
94 92
93 #return height and width of plot in inches from profile
94 plot_size_from_nb_onto <- function(profile){
95 width=10
96 range = seq(50, 2000, by=25)
97 names(range) = seq(8,242, by=3)
98 nb_onto = round(nrow(profile[[1]])/25)*25
99 height= as.integer(names(which(range==nb_onto)))
100 return (c(width,height))
101 }
102
95 make_plot <- function(profile,percent,title,onto,plot_opt){ 103 make_plot <- function(profile,percent,title,onto,plot_opt){
104
105 tmp <- plot_size_from_nb_onto (profile)
106 width <- tmp[1]
107 height <- tmp[2]
96 108
97 if (plot_opt == "PDF") { 109 if (plot_opt == "PDF") {
98 file_name=paste("profile_",onto,".pdf",collapse="",sep="") 110 file_name=paste("profile_",onto,".pdf",collapse="",sep="")
99 pdf(file_name) 111 pdf(file_name, width=width, heigh=height)
100 } else if (plot_opt == "JPEG"){ 112 } else if (plot_opt == "JPEG"){
101 file_name=paste("profile_",onto,".jpeg",collapse="",sep="") 113 file_name=paste("profile_",onto,".jpeg",collapse="",sep="")
102 jpeg(file_name) 114 jpeg(file_name,width=width, height=height, units = "in", res=100)
103 } else if (plot_opt == "PNG"){ 115 } else if (plot_opt == "PNG"){
104 file_name=paste("profile_",onto,".png",collapse="",sep="") 116 file_name=paste("profile_",onto,".png",collapse="",sep="")
105 png(file_name) 117 png(file_name,width=width, height=height, units = "in", res=100)
106 } 118 }
107 plotProfiles(profile, percentage=percent, multiplePlots=FALSE, aTitle=title) 119 plotProfiles(profile, percentage=percent, multiplePlots=FALSE, aTitle=title)
108 dev.off() 120 dev.off()
109 } 121 }
110 122
177 duplicate = args$duplicate 189 duplicate = args$duplicate
178 text_output = args$text_output 190 text_output = args$text_output
179 species=args$species 191 species=args$species
180 192
181 profiles = getprofile(input, id_type, level, duplicate,species) 193 profiles = getprofile(input, id_type, level, duplicate,species)
182 194
183 for (index in onto_pos) { 195 for (index in onto_pos) {
184 onto = names(profiles[index]) 196 onto = names(profiles[index])
185 profile=profiles[index] 197 profile=profiles[index]
186 make_plot(profile,per,title,onto,plotopt) 198 make_plot(profile,per,title,onto,plotopt)
187 text_output=paste("goProfiles_",onto,"_",title,".tsv",sep="",collapse="") 199 text_output=paste("goProfiles_",onto,"_",title,".tsv",sep="",collapse="")