Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • 3c9d2ab
  • /
  • UniversalPanMammalianClock
  • /
  • R_code
  • /
  • R_pgm4_ChromatinStateAnalysis
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge
swh:1:cnt:43f1596f7efc6b9bd66fc729c80eebb9d4db8b1f
directory badge
swh:1:dir:662723399e786304a67015f01c02cace05b0ff19

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
R_pgm4_ChromatinStateAnalysis
#(4)	Universal chromatin state analysis
#The following R code computes the summary statistics for the annotation of our top 1000 positively and negatively age-related CpGs based on universal chromatin state analysis. The code requires two input datasets: (1) hmm lists CpG and its corresponding chromatin state, and (2) summary statistics of our EWAS of age.
#
#R code
#
TopNum=1000
out.all={}

  ewas=subset(ewas,CpG%in%hmm$CpG)
  ewas=ewas[order(ewas$rank.Meta.Z),]
  ewas.pos=subset(ewas,Meta.Z>0)
  ewas.pos=ewas.pos[1:TopNum,]
  ewas.neg=subset(ewas,Meta.Z<0)
  ewas.neg=ewas.neg[1:TopNum,]
  #
  ck=is.element(ewas$CpG,hmm$CpG)
  #
  ewas.list=vector(len=2,mode='list')
  names(ewas.list)=c('pos','neg')
  ewas.list[[1]]=ewas.pos
  ewas.list[[2]]=ewas.neg
  for(ilist in 1:2){
    group=names(ewas.list)[[ilist]]
    #
    ewas.test=ewas.list[[ilist]]
    for(i in 1:n.states){
      anno=cpg.list[[i]]
      x.pos.cpg=intersect(anno$CpG,ewas.test$CpG);x.pos=length(x.pos.cpg)
      m=length(anno$CpG)#white balls
k=TopNum#number of draw
      ntot=nrow(ewas)
      n=ntot-m
      #odds ratio
      a=x.pos
      b=k-a
      c=m-a
      d=n-b
      odds.pos=(a*d)/(c*b)
      #obser x or > x
      p.enrich.pos=ifelse(odds.pos>=1,phyper(x.pos-1,m=m,n=n,k=k,lower.tail=F)
                          ,phyper(x.pos,m=m,n=n,k=k,lower.tail=T))
      #
      logp.enrich.pos=ifelse(odds.pos>=1,phyper(x.pos-1,m=m,n=n,k=k,lower.tail=F,log.p=T)
                             ,phyper(x.pos,m=m,n=n,k=k,lower.tail=T,log.p=T))
      logp.enrich.pos=logp.enrich.pos
      #
      sign.pos=ifelse(odds.pos>=1,1,-1)
      log10p.enrich.pos= -(logp.enrich.pos/log(10))*sign.pos
      #
      out1=data.frame(tissue=TISSUE[k.tissue],state=anno$state[1],group=group,TopNum=TopNum,N.overlap= x.pos,
                      OddsRatio=odds.pos,Hyper.P=p.enrich.pos,log10P=log10p.enrich.pos)
      out.all=rbind(out.all,out1)
      rm(a,b,c,d,x.pos,odds.pos)
      #
    }#end state
  }#end ilist

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API