[BioC] follow-up: How to "merge" cel.containers ?

Laurent Gautier laurent@genome.cbs.dtu.dk
Mon, 6 May 2002 10:02:08 +0200


On Mon, May 06, 2002 at 10:28:41AM +0200, julien.sylvestre@wotan.ens.fr wrote:
> OK. Thanks to your explanations and tips that really helped me.
> 
> I still have a minor problem when working with cel containers, which I agree appear more flexible.
> 
> How can i merge cel.containers (like 2 cel.containers, with each one containing 2 chips normalized in a pairwise fashion) ?
> Is there a convenient function like 'union' for plobs that allows one to do that easily ?


No... (not yet ?)...

I admit it can appear cumbersome for novice users.
(try class?container and class?Cel.container).

The function below should do the job.



union.container.Cel <- function(...) {
  n <- sum(unlist(lapply(list(...), length)))
  union <- new("Cel.container", x=vector("list", length=n), content="Cel", locked=FALSE)
  offset <- 0
  for (i in 1:length(list(...))) {
    if (i>1)
      offset <- offset + length(list(...)[[i-1]])
    for (j in 1:length(list(...)[[i]]))
      #show(list(...)[[i]])
      union[[offset+j]] <- list(...)[[i]][[j]]    
  }
  return(union)
}


Example:

data(listcel)
listcel2 <- listcel

u <- union.container.Cel(listcel, listcel2)






Hopin' it helps,




Laurent







> 
> Thanks.
> 
> JS.
> 


--------------------------------------------------------------
Laurent Gautier			CBS, Building 208, DTU
PhD. Student			D-2800 Lyngby,Denmark	
tel: +45 45 25 24 85		http://www.cbs.dtu.dk/laurent