[BioC] Using htmlpage
James W. MacDonald
jmacdon at med.umich.edu
Thu Feb 5 15:42:21 CET 2009
Hi John,
john seers (IFR) wrote:
> Hi Jim
>
>> True. However, nothing comes free. The cost of having a namespace is
>> that it is not simple to add functionality. The benefit is the
>> minimization of function masking by other packages and/or things in the
>
>> workspace.
>
> Is there no way to call a user function from a namespaced package?
As others have mentioned, you can get unexported things from a namespace
using the ':::' function. But I believe you really want the converse -
to stuff your function into the namespace and have the package think it
belongs there. While there may be programmatic ways around it, by far
the easiest way is to add a function to a source package and then
build/install.
You don't need to build R from source to build and install packages. All
you need to do is to get set up to be able to build R, and then you will
be able to install packages. In the past this was a semi-difficult thing
to do, but these days Duncan Murdoch has an installer that makes it
practically painless.
http://cran.r-project.org/bin/windows/base/rw-FAQ.html#Can-I-install-packages-into-libraries-in-this-version_003f
Alternatively, you can modify the sources and use the win-builder to
make an installable Windows package.
http://win-builder.r-project.org/
But personally, I would recommend getting set up to build packages
yourself. It's not that hard, and you gain two really nice things.
First, you will be able to install packages for which there is only a
source version. I can't tell you how often I have needed this capability.
Second, you get all these nice Unix tools that turn out to be
exceptionally useful (who knew?). Things like sed, cut, awk, etc can be
daunting to use at first, but they are so very useful for doing what
they do that I can no longer imagine a life where I would have to muddle
along using the exceptionally dull tools that are typically available on
Windows.
>
>> But then again, I could be completely wrong.
>
> No, you have it spot on.
>
>
>> I can divine that you want something like
>> getQuery4ENS(ids, species)
>
> I wondered if using the "..." notation would be a good idea.
>
> I am not sure how it works exactly but:
>
> getQuery4ENS(ids, ...)
>
> would mean you could pass through whatever you wanted, I think.
Yes you could. However, the ellipsis is designed to pass arbitrary
variables to underlying code. You would then have to write code to parse
whatever random things an end user might pass via that method and then
try to divine what they meant to do. And I am just not that imaginative.
Since the only additional argument we need is the species, it is much
more directed and simpler to add a species argument, and possibly do
some error checking to ensure that what is passed will be sensible to
the Ensembl web server (e.g., did they give you Homo_sapiens rather than
H_sapiens or Homo sapiens or H. sapiens).
Here you could either be friendly and try to munge what was passed into
the correct format, or just error out with a message stating what the
format needs to be. And I am not that friendly ;-D.
>
>
> If you think adding the functionality is a good idea then great and
> thank you. You will be the better judge of whether it fits with your
> design and is a sensible thing to do. I will definitely use it if it
> comes available.
I have been meaning to add Ensembl, so this gives me that much more
impetus. It won't be for a couple of days though.
Best,
Jim
>
>
>
>
> Regards
>
>
> John
>
>
>
> -----Original Message-----
> From: bioconductor-bounces at stat.math.ethz.ch
> [mailto:bioconductor-bounces at stat.math.ethz.ch] On Behalf Of James W.
> MacDonald
> Sent: 04 February 2009 20:17
> To: john seers (IFR)
> Cc: bioconductor at stat.math.ethz.ch
> Subject: Re: [BioC] Using htmlpage
>
> Hi John,
>
> john seers (IFR) wrote:
>> Hi Jim
>>
>> Thanks for the reply.
>>
>>> Easily is in the eye of the beholder.
>> Easily is in the eye of the user. It could be easier.
>
> True. However, nothing comes free. The cost of having a namespace is
> that it is not simple to add functionality. The benefit is the
> minimization of function masking by other packages and/or things in the
> workspace.
>
> The other side of the coin is the poor soul in a world without
> namespaces who wonders why htmlpage() doesn't work, unaware that the
> object getCells in his workspace is clobbering the getCells() function
> that he knows nothing about.
>
>>> you will need to add the functions to the source package and then
>>> build/install.
>> I thought that might be the answer. I do not really want to do that
>> because I do not build R from source. It would also create a
> maintenance
>> problem.
>>
>>> What repository are you trying to add?
>> I was building links to www.ensembl.org.
>>
>>
> ########################################################################
>> ###################
>>
>> I notice that you are one of the authors Jim, so can I add a further
>> question/suggested enhancement.
>>
>> One of the links that I am building for www.ensembl.org needs more
> than
>> the id to build the query. So I need the helper function to use the id
>> plus further information from one of the other columns. Is there a
>> recognised way to do this? That is pass the columns/lists through to
>> getCells/getQueryLink/helper function so it can build the link from
>> multiple values?
>
> I could probably add the functionality for you, but you will have to be
> less mysterious about what you want.
>
> I can divine that you want something like
>
> getQuery4ENS(ids, species)
>
> so that
>
> getQuery4ENS("ENSG00000064961", "Homo_sapiens")
>
> will build
>
> http://www.ensembl.org/Homo_sapiens/Search/Summary?species=Homo_sapiens;
> idx=;q=ENSG00000064961
>
> But then again, I could be completely wrong.
>
> Best,
>
> Jim
>
>> Regards
>>
>>
>> John
>>
>>
>>
>>
>>
>>
>> ---
>> -----Original Message-----
>> From: James W. MacDonald [mailto:jmacdon at med.umich.edu]
>> Sent: 04 February 2009 15:47
>> To: john seers (IFR)
>> Cc: bioconductor at stat.math.ethz.ch
>> Subject: Re: [BioC] Using htmlpage
>>
>> Hi John,
>>
>> john seers (IFR) wrote:
>>> Hello Bioconductor people
>>>
>>> I am trying to use htmlpage (from the annotate package) so it can
>>> generate html links in addition to the types of links already
>> provided.
>>> >From the documentation of htmlpage it says:
>>>
>>> "Additional repositories can easily be added. See getQueryLink for
>> more
>>> information."
>> Easily is in the eye of the beholder. It is actually quite easy, but
> you
>> will need to add the functions to the source package and then
>> build/install. As you have noted, the namespace prevents you from
> easily
>> modifying the package by dumping new functions in the workspace.
>>
>> What repository are you trying to add? It might be easiest to just add
>
>> the repository to the package itself, if it is something that others
>> might want to use.
>>
>> Best,
>>
>> Jim
>>
>>
>>> But it does not seem as straightforward as I hoped. Trying to modify
>> the
>>> scripts hits difficulties with namespaces and local names. Can anyone
>>> tell me if there is a simpler way?
>>>
>>> I defined my own copy of getQueryLink but htmlpage still called the
>>> namespace version. This I could change using:
>>>
>>> assignInNamespace("getQueryLink", getQueryLink, ns="annotate")
>>>
>>> But then it did not work because getQueryLink could not see the
>> original
>>> internal scripts such as getQuery4Affy. So I modified the script
> again
>>> to remove all the repositories I did not need. But I still needed the
>>> getQuery4Affy helper script so I had to redefine that and use
>>> assignInNamespace again.
>>>
>>> This seems too complicated. Have I missed an easier way? Any
>>> suggestions?
>>>
>>>
>>>
>>>
>>> Regards
>>>
>>>
>>> John
>>>
>>>
>>>
>>>
> ########################################################################
>>> ################################
>>>
>>>
>>>> sessionInfo()
>>> R version 2.8.1 (2008-12-22)
>>> i386-pc-mingw32
>>>
>>> locale:
>>> LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United
>>> Kingdom.1252;LC_MONETARY=English_United
>>> Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252
>>>
>>> attached base packages:
>>> [1] tools stats graphics grDevices datasets utils
>> methods
>>> [8] base
>>>
>>> other attached packages:
>>> [1] annotate_1.20.1 xtable_1.5-4 AnnotationDbi_1.4.2
>>> [4] Biobase_2.2.1 RWinEdt_1.8-0
>>>
>>> loaded via a namespace (and not attached):
>>> [1] DBI_0.2-4 RSQLite_0.7-1
>>>
>>>
>>>
>>>
>>> ---
>>>
>>> _______________________________________________
>>> Bioconductor mailing list
>>> Bioconductor at stat.math.ethz.ch
>>> https://stat.ethz.ch/mailman/listinfo/bioconductor
>>> Search the archives:
>> http://news.gmane.org/gmane.science.biology.informatics.conductor
>>
>
--
James W. MacDonald, M.S.
Biostatistician
Hildebrandt Lab
8220D MSRB III
1150 W. Medical Center Drive
Ann Arbor MI 48109-0646
734-936-8662
More information about the Bioconductor
mailing list