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

swh:1:snp:0fa5e44aa9eaf68dc00949be32686577b750591b
  • Code
  • Branches (8)
  • Releases (0)
    • Branches
    • Releases
    • HEAD
    • refs/heads/ahaghani-patch-1
    • refs/heads/main
    • refs/tags/3.1.1
    • refs/tags/v1.0.0
    • refs/tags/v2.0.0
    • refs/tags/v2.1.0
    • refs/tags/v3.0.0
    • refs/tags/v3.1.0
    No releases to show
  • ad54dd7
  • /
  • FundamentalEquations
  • /
  • Codes_AROCM
  • /
  • 2_slopeV6.R
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
  • revision
  • snapshot
content badge
swh:1:cnt:7f0fbf1b9a91ec799b65dc3e8530ec29fe2092f4
directory badge
swh:1:dir:31c47d3bca4920f4bdf7ceba2d4ce97d229dc7ec
revision badge
swh:1:rev:8575912e5aa73fde6ab54bba4fbaeadc7d8267f4
snapshot badge
swh:1:snp:0fa5e44aa9eaf68dc00949be32686577b750591b

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
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: 8575912e5aa73fde6ab54bba4fbaeadc7d8267f4 authored by Amin Haghani on 20 November 2024, 18:45:15 UTC
Delete MammalianNetworkAnalysis, Amin Haghani/Supplementary Data directory
Tip revision: 8575912
2_slopeV6.R
library(colorspace)
require(RNOmni)
require(glmnet)
require(caret)
library(plyr)
library(RColorBrewer)
# library(WGCNA)
library(tidyverse)
library(readxl)

outfolder = 'out_AROCM_0.1L'
freq = 5 ##### to include lemurs
anAge <- read.csv("/Users/feiz/Dropbox/MammalianMethCombined/StuffCaesar/anAgeUpdatedCaesarVersion51.csv")
source("Codes_AROCM/1_prepare_data.R")
colSums(is.na(dat1))
dim(dat1)
dim(SpeciesMat)
colSums(is.na(SpeciesMat))
source("lemur.R")

sort(unique(substr(dat1$Folder,1,4)))
tmpd = dat1%>%filter(substr(dat1$Folder,1,4) %in% c("N109"))
table(tmpd$SpeciesLatinName)
# View(dat1%>%filter(substr(dat1$Folder,1,4) %in% c("N119")))
# View(AllSamp%>%filter(substr(AllSamp$Folder,1,4) == "N110"))
## N93, Tursiops aduncus
match("205600840063_R01C01", colnames(dat0sesame))

shrew = dat1%>%filter(SpeciesLatinName=="Sorex cinereus")
table(shrew$Tissue)

shrewnew = rbind(shrew%>%filter(Tissue == "Fetus"),
                 shrew%>%filter(Tissue == "Fetus"))
shrewnew$Tissue = rep(c("Liver","Tail"), each=3)

dat1 = rbind(dat1,shrewnew)
tmp1 = unique(substr(dat1$MammalNumberHorvath,1,3))
tmp1 = strsplit(dat1$MammalNumberHorvath,".",fixed = TRUE)
tmp2 = sapply(tmp1, function(l){
  paste(l[1],l[2], sep=".")
})
sort(unique(tmp2))
dat1$SubOrder = tmp2

write.csv(dat1, paste0(outfolder, "/datSample_slope_",Sys.Date(),".csv"))
########## calculate slopes


permute = FALSE
scaleCpG = TRUE
name1 = ifelse(scaleCpG, "IdentityScaled", "Identity")

states
statesPRC2

library(dplyr)
props = c(1:10)/10  ### 1.00 0.50 0.40 0.30 0.20 0.15 0.10
oldprops = c(1, 1.5, 2)
dim(SpeciesMat)
head(colnames(SpeciesMat), 22)
SpeciesMat = SpeciesMat[,c(1:16)]

source("Codes_AROCM/0_fns_v2.R")
vnum = "v13"
cex.main=1.5
cut1 = freq = 3
j=2
for (j in 1:length(statesPRC2)) {
  cgid = cg_list[[j]]
  len1 = statesPRC2[j]
  
  ## source("Codes_AROCM/3_fitslopeV5.R")
  source("Codes_AROCM/3_fitslopeV8.R")
}

dim(SpeciesMat)
colSums(!is.na(SpeciesMat))[1:42]
####RemoveFei
{
  SpeciesMat$RemoveFei[SpeciesMat$Freq < cut1] = 1
  
  SpeciesMat$RemoveFei[SpeciesMat$MammalNumberHorvath %in% 
                         c("1.3.3","1.3.9", "1.7.1","4.13.2","4.13.11")] = 1
  
  SpeciesMat$RemoveFei[SpeciesMat$MammalNumberHorvath %in% c("1.4.3","6.1.1") &
                         SpeciesMat$Tissue %in% c("Muscle")] = 1
  
  SpeciesMat$RemoveFei[SpeciesMat$MammalNumberHorvath=="4.19.1" &
                         SpeciesMat$Tissue %in% c("Skin")] = 1
  
  SpeciesMat$RemoveFei[SpeciesMat$MammalNumberHorvath=="9.9.1" &
                         SpeciesMat$Tissue %in% c("Brain")] = 1
  SpeciesMat$RemoveFei[SpeciesMat$MammalNumberHorvath=="9.9.3" &
                         SpeciesMat$Tissue %in% 
                         c("Pituitary","Hippocampus", "Hypothalamus")] = 1
  
}

write.csv(SpeciesMat, 
          paste0(outfolder,"/ALL_states_",name1,"_SpeciesTissue_13Slopes_",vnum,".csv"))

### Supplement Table 1
SuppTab1 = read.csv("out0314_TissueSlopes/ALL_states_IdentityScaled_SpeciesTissue_13Slopes_v10.csv",
                    row.names = 1)
head(colnames(SuppTab1),22)
table(SuppTab1$RemoveFei)
SuppTab1 = SuppTab1[SuppTab1$RemoveFei== 0,]
SuppTab1 = SuppTab1[, -(16:17)]
SuppTab1$SpeciesCommonName = NA
m1 = match(SuppTab1$SpeciesLatinName, dat1$SpeciesLatinName)
table(is.na(m1))
SuppTab1$SpeciesCommonName[!is.na(m1)] = dat1$SpeciesCommonName[m1[!is.na(m1)]]
SuppTab1 = SuppTab1[,c(1,718,2:717)]

m2 = match(SuppTab1$SpeciesLatinName, substr(anAgeUse$MammalNumberHorvath,1,3))
SuppTab1$SpeciesLatinName[!is.na(m2)] = anAgeUse$Family[m2[!is.na(m2)]]
View(SuppTab1%>%filter(is.na(SpeciesCommonName)))

SuppTab1$SpeciesCommonName[is.na(SuppTab1$SpeciesCommonName)] = 
  SuppTab1$SpeciesLatinName[is.na(SuppTab1$SpeciesCommonName)]
idx1 = with(SuppTab1,which(SpeciesCommonName == SpeciesLatinName))
SuppTab1$MammalNumberHorvath[idx1] = 
  substr(SuppTab1$MammalNumberHorvath[idx1],1,3)

View(SuppTab1%>%filter(SpeciesCommonName == SpeciesLatinName))

tmpd = read.csv("/Users/feiz/Dropbox/HorvathLabCoreMembers/Josh/ProjectSlope/Article/SupplementalTables/SupplementTable1_v1.csv",
                row.names = 1,check.names=FALSE)
View(cbind(colnames(SuppTab1)[1:16],
           colnames(tmpd)[1:16]))
colnames(SuppTab1)[1:16] = colnames(tmpd)[1:16]
colnames(SuppTab1)[-(1:16)] = substring(colnames(SuppTab1)[-(1:16)],15)

write.csv(SuppTab1%>%
            arrange(SpeciesLatinName), "SupplementTable1_v2.csv",row.names = FALSE)


source("slopes_mat.R")

colnames(corrmat)
dim(corrmat)
ragemat = cbind(SpeciesMat[,1:16], corrmat[,-(1:13)])
colnames(ragemat)
sd_ragemat = ragemat%>%select(contains("sd_rage"))

write.csv(ragemat, paste0(outfolder,"/SpeciesTissueRelativeAge.csv"))

### NEXT
### 4_plots.R


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