Skip to content

Commit

Permalink
added all sh (slurm) and R scripts outside scripts dir
Browse files Browse the repository at this point in the history
  • Loading branch information
stivalaa committed Jan 7, 2023
1 parent 51c21e3 commit d593755
Show file tree
Hide file tree
Showing 207 changed files with 6,890 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

#SBATCH --job-name="gensim_dk0"
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=1
#SBATCH --time=0-0:10:00
#SBATCH --output=gensim_dk0-%j.out
#SBATCH --error=gensim_dk0-%j.err

uname -a
echo Started at `date`

Rscript ../../scripts/generateSimulatedNetworksFromErdosRenyiModel.R greysanatomy_edgelist.txt simulated/dk0

echo Ended at `date`
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

#SBATCH --job-name="gensim_dkseries"
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=1
#SBATCH --time=0-0:10:00
#SBATCH --output=gensim_dkseries-%j.out
#SBATCH --error=gensim_dkseries-%j.err

uname -a
echo Started at `date`

for dk in 0 1 2 2.1 2.5
do
dk_no_period=`echo "${dk}" | sed 's/[.]//g'`
../../scripts/generateSimulatedNetworksFromDKseries.sh $dk greysanatomy_edgelist.txt simulated/dk${dk_no_period}
done

echo Ended at `date`
17 changes: 17 additions & 0 deletions GreysAnatomy/dkseries/get_greysanatomy_data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
###
### File: get_greysanatomy_data.R
### Author: Alex Stivala
### Created: May 2020
###
### Load the Greys Anataomyh network and convert to plain edgelist
### (no attributes) for RandNetGen
###

library(statnet)

source('../statnet_estimations/load_greysanatomy_data.R')

grey.net <- load_greysanatomy_data()

el <- as.edgelist(grey.net)-1 # convertt to 0-based not 1-based
write.table(el, 'greysanatomy_edgelist.txt', col.names=F, row.names=F)
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

#SBATCH --job-name="atomic_dkseries"
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=1
#SBATCH --time=0-0:40:00
#SBATCH --output=atomic_dkseries-%j.out
#SBATCH --error=atomic_dkseries-%j.err

uname -a
echo Started at `date`

SCRIPTDIR=../../scripts



OBS_ATOMICCYCLETAB=greysanatomy_atomiccycletable.txt

#
# generate tables using FindAtomicCycles
# (only run if not exist; so to regneraet remove these files first)
#

if [ ! -f $OBS_ATOMICCYCLETAB ]; then
time $SCRIPTDIR/makeSingleNetworkAtomicCycleLengthDistributionTable.sh greysanatomy_edgelist.txt > ${OBS_ATOMICCYCLETAB}
fi


for dk in 0 1 2 21 25
do
ATOMICTAB=dk${dk}_atomiccycledisttable.txt
if [ ! -f $ATOMICTAB ]; then
time $SCRIPTDIR/makeAtomicCycleLengthDistributionTables.sh simulated/dk${dk}/ > ${ATOMICTAB}
fi
# generate plots from tables with R
dktitle=`echo $dk | sed 's/21/2.1/;s/25/2.5/'`
time Rscript $SCRIPTDIR/plotCycleLengthDistributionsFromTables.R "dk-series $dktitle k" 'geodesic cycle' ${ATOMICTAB} ${OBS_ATOMICCYCLETAB}
done


echo Ended at `date`
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

#SBATCH --job-name="plot_max_geodesic_cycle2"
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=1
#SBATCH --mem-per-cpu=4GB
#SBATCH --time=0-0:10:00
#SBATCH --output=plot_max_geodesic_cycle2-%j.out
#SBATCH --error=plot_max_geodesic_cycle2-%j.err

uname -a
echo Started at `date`

module load r

SCRIPTDIR=../../scripts


Rscript $SCRIPTDIR/plotCombinedMaxCycleLengthDistributionsFromTables.R 'geodesic cycle' ../statnet_estimations/model5_geodesiccycledisttable.txt "dk*_geodesiccycledisttable.txt" greysanatomy_geodesiccycletable.txt greysanatomy_combined2_max_geodesic.eps

echo Ended at `date`
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

#SBATCH --job-name="plot_max_geodesic_cycle"
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=1
#SBATCH --mem-per-cpu=4GB
#SBATCH --time=0-0:10:00
#SBATCH --output=plot_max_geodesic_cycle-%j.out
#SBATCH --error=plot_max_geodesic_cycle-%j.err

uname -a
echo Started at `date`

SCRIPTDIR=../../scripts


Rscript $SCRIPTDIR/plotCombinedMaxCycleLengthDistributionsFromTables.R 'geodesic cycle' ../statnet_estimations/model5_atomiccycledisttable.txt "dk*_atomiccycledisttable.txt" greysanatomy_atomiccycletable.txt greysanatomy_combined_max_geodesic.eps

echo Ended at `date`
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

#SBATCH --job-name="geodesic_dkseries"
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=1
#SBATCH --time=0-0:40:00
#SBATCH --output=geodesic_dkseries-%j.out
#SBATCH --error=geodesic_dkseries-%j.err

uname -a
echo Started at `date`

SCRIPTDIR=../../scripts

module load r

OBS_GEODESICCYCLETAB=greysanatomy_geodesiccycletable.txt

#
# generate tables using FindGeodesicCycles
# (only run if not exist; so to regneraet remove these files first)
#

if [ ! -f $OBS_GEODESICCYCLETAB ]; then
time $SCRIPTDIR/makeSingleNetworkGeodesicCycleLengthDistributionTable.sh greysanatomy_edgelist.txt > ${OBS_GEODESICCYCLETAB}
fi


for dk in 0 1 2 21 25
do
GEODESICTAB=dk${dk}_geodesiccycledisttable.txt
if [ ! -f $GEODESICTAB ]; then
time $SCRIPTDIR/makeGeodesicCycleLengthDistributionTables.sh simulated/dk${dk}/ > ${GEODESICTAB}
fi
# generate plots from tables with R
dktitle=`echo $dk | sed 's/21/2.1/;s/25/2.5/'`
time Rscript $SCRIPTDIR/plotCycleLengthDistributionsFromTables.R "dk-series $dktitle k" 'geodesic cycle' ${GEODESICTAB} ${OBS_GEODESICCYCLETAB}
done


echo Ended at `date`
27 changes: 27 additions & 0 deletions GreysAnatomy/dkseries/run_simfit_plots_slurm_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

#SBATCH --job-name="gof"
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=1
#SBATCH --mem-per-cpu=4GB
#SBATCH --time=0-0:10:00
#SBATCH --output=gof_simfit-%j.out
#SBATCH --error=gof_simfit-%j.err

uname -a
echo Started at `date`

SCRIPTDIR=../../scripts


OBS_EDGELIST=greysanatomy_edgelist.txt

time Rscript $SCRIPTDIR/plotUndirectedSimFit.R $OBS_EDGELIST "../statnet_estimations/simulated/model5/sim_model5_*_edgelist.txt" statnet_model5_simfit_gof.pdf

for dk in 0 1 2 21 25
do
time Rscript $SCRIPTDIR/plotUndirectedSimFit.R $OBS_EDGELIST "simulated/dk${dk}/sim_modeldk${dk}_*_edgelist.txt" dk${dk}_simfit_gof.pdf
done

echo Ended at `date`
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

#SBATCH --job-name="gensim_model1"
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=1
#SBATCH --time=0-0:10:00
#SBATCH --output=gensim_model1-%j.out
#SBATCH --error=gensim_model1-%j.err

uname -a
echo Started at `date`

/usr/bin/time Rscript ../../scripts/generateSimulatedNetworksFromStatnetModel.R model1.RData simulated/model1

echo Ended at `date`
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

#SBATCH --job-name="gensim_model5"
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=1
#SBATCH --time=0-0:10:00
#SBATCH --output=gensim_model5-%j.out
#SBATCH --error=gensim_model5-%j.err

uname -a
echo Started at `date`

/usr/bin/time Rscript ../../scripts/generateSimulatedNetworksFromStatnetModel.R model5.RData simulated/model5

echo Ended at `date`
30 changes: 30 additions & 0 deletions GreysAnatomy/statnet_estimations/load_greysanatomy_data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
###
### File: load_greysanatomy_data.R
### Author: Alex Stivala
### Created: August 2019
###
### Load the Grey's Anatomy Hookups data and return statnet network object.
### Code taken from
### SNA in R Workshop
### Administered at the University of Southern California
### by Alex Leavitt & Joshua Clark
### PhD students at the Annenberg School for Communication & Journalism
### adapted from materials by Katya Ognyanova and the BadHessian blog
### https://github.com/alexleavitt/SNAinRworkshop
###

library(statnet)


load_greysanatomy_data <- function() {
ga.el<-read.table('../data/grey_edgelist.tsv', sep="\t", header=T, quote="\"",
stringsAsFactors=F, strip.white=T, as.is=T)

ga.atts<-read.table('../data/grey_nodes.tsv', sep="\t", header=T, quote="\"",
stringsAsFactors=F, strip.white=T, as.is=T)
grey.net<-network(ga.el, vertex.attr=ga.atts,
vertex.attrnames=colnames(ga.atts), directed=F, hyper=F,
loops=F, multiple=F, bipartite=F)
return(grey.net)
}

35 changes: 35 additions & 0 deletions GreysAnatomy/statnet_estimations/plotGreysAnatomyNetwork.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env Rscript
###
### File: plotGreysAnatomyNetwork.R
### Author: Alex Stivala
### Created: August 2019
###
### Make visualization of Greys Anatomy 'hookups' social network.
###
### code adapted from
### SNA in R Workshop
### Administered at the University of Southern California
### by Alex Leavitt & Joshua Clark
### PhD students at the Annenberg School for Communication & Journalism
### adapted from materials by Katya Ognyanova and the BadHessian blog
### https://github.com/alexleavitt/SNAinRworkshop
### https://badhessian.org/2012/09/lessons-on-exponential-random-graph-modeling-from-greys-anatomy-hook-ups/
###
### Usage: plotGreysAnatomyNetwork.R
###
###
### Output is to file
### 'greysanatomy_network.eps'
### WARNING: overwrites output files if they exist
###


source('load_greysanatomy_data.R')


grey.net <- load_greysanatomy_data()
summary(grey.net)
postscript('greysanatomy_network.eps')
plot(grey.net, vertex.col=c("blue","pink")[1+(get.vertex.attribute(grey.net, "sex")=="F")], label=get.vertex.attribute(grey.net, "name"), label.cex=.75)
dev.off()

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash

#SBATCH --job-name="cypath_model1"
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=1
#SBATCH --time=0-0:10:00
#SBATCH --output=cypath_model1-%j.out
#SBATCH --error=cypath_model1-%j.err

uname -a
echo Started at `date`

SCRIPTDIR=../../scripts

ATOMICTAB=model1_atomiccycledisttable.txt
CHORDLESSTAB=model1_chordlesscycledisttable.txt
CYCLETAB=model1_cycledisttable.txt


OBS_ATOMICCYCLETAB=greysanatomy_atomiccycletable.txt
OBS_CHORDLESSCYCLETAB=greysanatomy_chordlesscycletable.txt
OBS_CYCLETAB=greysanatomy_cycletable.txt

#
# generate tables using CYPATH or FindAtomicCycles
# (only run if not exist; so to regneraet remove these files first)
#
if [ ! -f $ATOMICTAB ]; then
time $SCRIPTDIR/makeAtomicCycleLengthDistributionTables.sh simulated/model1/ > ${ATOMICTAB}
fi

if [ ! -f $CHORDLESSTAB ]; then
time $SCRIPTDIR/makeCycleLengthDistributionTables.sh C simulated/model1/ > ${CHORDLESSTAB}
fi

if [ ! -f $CYCLETAB ]; then
time $SCRIPTDIR/makeCycleLengthDistributionTables.sh c simulated/model1 > ${CYCLETAB}
fi

if [ ! -f $OBS_ATOMICCYCLETAB ]; then
time $SCRIPTDIR/makeSingleNetworkAtomicCycleLengthDistributionTable.sh greysanatomy_edgelist.txt > ${OBS_ATOMICCYCLETAB}
fi

if [ ! -f $OBS_CHORDLESSCYCLETAB ]; then
time $SCRIPTDIR/makeSingleNetworkCycleLengthDistributionTable.sh C greysanatomy_edgelist.txt > ${OBS_CHORDLESSCYCLETAB}
fi

if [ ! -f $OBS_CYCLETAB ]; then
time $SCRIPTDIR/makeSingleNetworkCycleLengthDistributionTable.sh c greysanatomy_edgelist.txt > ${OBS_CYCLETAB}
fi

#
# generate plots from tables with R
#
time Rscript $SCRIPTDIR/plotCycleLengthDistributionsFromTables.R 'ERGM' 'geodesic cycle' ${ATOMICTAB} ${OBS_ATOMICCYCLETAB}

time Rscript $SCRIPTDIR/plotCycleLengthDistributionsFromTables.R 'ERGM' 'chordless cycle' ${CHORDLESSTAB} ${OBS_CHORDLESSCYCLETAB}

time Rscript $SCRIPTDIR/plotCycleLengthDistributionsFromTables.R 'ERGM' 'cycle' ${CYCLETAB} ${OBS_CYCLETAB}

echo Ended at `date`
Loading

0 comments on commit d593755

Please sign in to comment.