r - Highlighting regions in ggplot2 barplot fulfilling a condition -


i want plot horizontal barplot using ggplot2 , highlight regions satisfying particular criteria.

in case, if "term" point "e15.5-e18.5_up_down" has more twice number of samples compared point "p22-p29_up_down" , vice-versa, highlight label or region.

i have dataframe in following format:

clid    clsz    goid    nodesize    samplematch phyper  padj    term    ont samplekeys e15.5-e18.5_up_down 1364    go:0007568  289 20  0.141830716154421   1   aging   bp  ensmusg00000049932 ensmusg00000046352 ensmusg00000078249 ensmusg00000039428 ensmusg00000014030 ensmusg00000039323 ensmusg00000026185 ensmusg00000027513 ensmusg00000023224 ensmusg00000037411 ensmusg00000020429 ensmusg00000020897 ensmusg00000025486 ensmusg00000021477 ensmusg00000019987 ensmusg00000023067 ensmusg00000031980 ensmusg00000023070 ensmusg00000025747 ensmusg00000079017 e15.5-e18.5_up_down 1364    go:0006397  416 3   0.999999969537913   1   mrna processing bp  ensmusg00000027510 ensmusg00000021210 ensmusg00000027951 p22-p29_up_down 476 go:0007568  289 11  0.0333771791166823  1   aging   bp  ensmusg00000049932 ensmusg00000037664 ensmusg00000026879 ensmusg00000026185 ensmusg00000026043 ensmusg00000060600 ensmusg00000022508 ensmusg00000020897 ensmusg00000028702 ensmusg00000030562 ensmusg00000021670 p22-p29_up_down 476 go:0006397  416 2   0.998137879564768   1   mrna processing bp  ensmusg00000024007 ensmusg00000039878 

reduced (only terms necessary plotting):

clid    samplematch term e15.5-e18.5_up_down 20  aging p22-p29_up_down 2   mrna processing e15.5-e18.5_up_down 3   mrna processing p22-p29_up_down 11  aging 

i prefer general approach work condition, not 1 need scenario. 1 way imagined use sapply each pair of clid/term , create column stores if criteria fulfilled boolean, still cannot find way highlight values. efficient way achieve ?

pseudo-code approach:

for(i in clid) {     for(k in clid) {         if (term[i] == term[k]) {             condition = check(term[i], term[k]) #check if samplematch count any clid/term pair higher compared corresponding clid/term pair             if (condition == true) {                 highlight(term)                 }             }         }     } 

in end want (highlighting label or column): enter image description here

or this: highlight data individually facet_grid in r.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -