SegmentedCopyNumbers       package:aroma.core       R Documentation

_T_h_e _S_e_g_m_e_n_t_e_d_C_o_p_y_N_u_m_b_e_r_s _c_l_a_s_s

_D_e_s_c_r_i_p_t_i_o_n:

     Package:  aroma.core 
      *Class SegmentedCopyNumbers*

     'Object'
      '~~|'
      '~~+--''RawGenomicSignals'
      '~~~~~~~|'
      '~~~~~~~+--''RawCopyNumbers'
      '~~~~~~~~~~~~|'
      '~~~~~~~~~~~~+--''SegmentedGenomicSignalsInterface'
      '~~~~~~~~~~~~~~~~~|'
      '~~~~~~~~~~~~~~~~~+--''SegmentedCopyNumbers'

     *Directly known subclasses:*


     public static class *SegmentedCopyNumbers*
      extends SegmentedGenomicSignalsInterface

_U_s_a_g_e:

     SegmentedCopyNumbers(..., states=NULL)

_A_r_g_u_m_e_n_t_s:

     ...: Arguments passed to 'RawCopyNumbers'.

  states: A 'function' returning the copy-number states given a
          'vector' of locus positions.

_F_i_e_l_d_s _a_n_d _M_e_t_h_o_d_s:

     *Methods:*
      _No methods defined_.

     *Methods inherited from SegmentedGenomicSignalsInterface*:
      as.data.frame, binnedSmoothingByState, extractSubsetByState,
     getStateColorMap, getStateColors, getStates, getUniqueStates,
     kernelSmoothingByState, plot, points, setStateColorMap, setStates

     *Methods inherited from RawCopyNumbers*:
      as.data.frame, cnRange, extractRawCopyNumbers, getCn, getCNs,
     plot

     *Methods inherited from RawGenomicSignals*:
      addBy, addLocusFields, append, applyBinaryOperator,
     as.data.frame, binnedSmoothing, divideBy,
     estimateStandardDeviation, extractDataForSegmentation,
     extractRegion, extractSubset, gaussianSmoothing, getChromosome,
     getLocusFields, getName, getPositions, getSigma, getSignals,
     getWeights, getXScale, getXY, getYScale, hasWeights,
     kernelSmoothing, lines, multiplyBy, nbrOfLoci, plot, points,
     setLocusFields, setName, setSigma, setWeights, setXScale,
     setYScale, signalRange, sort, subtractBy, summary, xMax, xMin,
     xRange, xSeq, yMax, yMin, yRange

     *Methods inherited from Object*:
      asThis, $, $<-, [[, [[<-, as.character, attach, attachLocally,
     clearCache, clone, detach, equals, extend, finalize, gc,
     getEnvironment, getFields, getInstantiationTime,
     getStaticInstance, hasField, hashCode, ll, load, objectSize,
     print, registerFinalizer, save

_A_u_t_h_o_r(_s):

     Henrik Bengtsson (<URL: http://www.braju.com/R/>)

_E_x_a_m_p_l_e_s:

     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     # Simulating copy-number data
     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     # True CN states
     stateFcn <- function(x, ...) {
       states <- integer(length(x))
       states[200 <=x & x <= 300] <- -1L
       states[650 <=x & x <= 800] <- +1L
       states
     }

     # Number of loci
     J <- 1000

     y <- rnorm(J, sd=1/2)
     x <- 1:length(y)
     for (state in c(-1,+1)) {
       idxs <- (stateFcn(x) == state)
       y[idxs] <- y[idxs] + state
     }

     cn <- SegmentedCopyNumbers(y, x, states=stateFcn)
     print(cn)

     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     # Subsetting
     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     plot(cn, ylim=c(-4,4))
     title("Copy numbers annotated by state (and subset by state)")

     cnS <- extractSubsetByState(cn, states=c(0,+1L))
     print(cnS)
     points(cnS, pch=21, cex=1.2, lwd=2, col="purple")

     legend("topright", pch=c(19, 21), col=c("#999999", "purple"), sprintf(c("raw [n=%d]", "CN in {0,1} [n=%d]"), c(nbrOfLoci(cn), nbrOfLoci(cnS))), bty="n")

     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     # Kernel smoothing stratified by state
     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     plot(cn, col="#999999", ylim=c(-3,3))
     title(main="Kernel smoothing stratified by state w/ Gaussian kernel")

     cnSa <- kernelSmoothingByState(cn, h=2)
     points(cnSa, col="blue")

     cnSb <- kernelSmoothingByState(cn, h=5)
     points(cnSb, col="red")

     legend("topright", pch=19, col=c("#999999", "blue", "red"), sprintf(c("raw [n=%d]", "N(.,sd=2) [n=%d]", "N(.,sd=5) [n=%d]"), c(nbrOfLoci(cn), nbrOfLoci(cnSa), nbrOfLoci(cnSb))), bty="n")

     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     # Binned smoothing stratified by state
     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     plot(cn, col="#999999", ylim=c(-3,3))
     title(main="Binned smoothing stratified by state")

     cnSa <- binnedSmoothingByState(cn, by=3)
     lines(cnSa, col="blue")
     points(cnSa, col="blue")

     cnSb <- binnedSmoothingByState(cn, by=9)
     lines(cnSb, col="red")
     points(cnSb, col="red")

     legend("topright", pch=19, col=c("#999999", "blue", "red"), sprintf(c("raw [n=%d]", "Bin(w=3) [n=%d]", "Bin(w=9) [n=%d]"), c(nbrOfLoci(cn), nbrOfLoci(cnSa), nbrOfLoci(cnSb))), bty="n")

