On 10/16/2013 06:32 AM, John linux-user wrote:
Hello everyone,

I am wondering how to simply merge two GRanges objects by range field and add 
the value by additional vector. For example, I have two objects below


Hi -- GRanges is from a Bioconductor package, so please ask on the Bioconductor mailing list

  http://bioconductor.org/help/mailing-list/

I think you might do hits = findOverlaps(obj1, obj2) to get indexes of overlapping ranges, then pmin(obj1[queryHits(obj1)], obj2[subjectHits(obj2)]) and pmax() to get start and end coordinates, and construct a new GRanges from those. If you provide an easily reproducile example (e.g., constructing some sample GRanges objects 'by hand' using GRanges()) and post to the Bioconductor mailing list you'll likely get a complete answer.

Martin

obj1

seqnames           ranges strand |       Val
             <Rle>        <IRanges>  <Rle> | <integer>
   [1] chr1_random [272531, 272571]      + |        88
   [2] chr1_random [272871, 272911]      + |        45

obj2
  seqnames           ranges strand |       Val
             <Rle>        <IRanges>  <Rle> | <integer>
   [1] chr1_random [272531, 272581]      + |        800
   [2] chr1_random [272850, 272911]      + |        450

after merged, it should be an object as the following mergedObject and it would 
concern the differences in IRANGE data (e.g. 581 and 850 in obj2 above were 
different from those of obj1, which were 571 and 871 respectively)

mergedObject

  seqnames           ranges strand                 |         object2Val   
object1Val
             <Rle>        <IRanges>  <Rle>         |         <integer>     
<integer>
   [1] chr1_random [272531, 272581]      + |        800               88
   [2] chr1_random [272850, 272911]      + |        450               45





On Wednesday, October 16, 2013 8:31 AM, Terry Therneau <thern...@mayo.edu> 
wrote:



On 10/16/2013 05:00 AM, r-help-requ...@r-project.org wrote:
Hello,

I'm trying to use coxph() function to fit a very simple Cox proportional
hazards regression model (only one covariate) but the parameter space is
restricted to an open set (0, 1). Can I still obtain a valid estimate by
using coxph function in this scenario? If yes, how? Any suggestion would be
greatly appreciated. Thanks!!!

Easily:
     1.  Fit the unrestricted model.  If the solution is in 0-1 you are done.
     2.  If it is outside, fix the coefficient.  Say that the solution is 1.73, 
then the
optimal solution under contraint is 1.
         Redo the fit adding the paramters  "init=1, iter=0".  This forces the 
program to
give the loglik and etc for the fixed coefficient of 1.0.

Terry Therneau

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
        [[alternative HTML version deleted]]



______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to