This repository has been archived by the owner on Aug 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
174 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/bash | ||
|
||
# Pipeline code to generate the ccdata structure | ||
|
||
|
||
DEFAULT_SPACES='xml' | ||
allPatients='all_patients.RData' | ||
allPatients_untime='delta_num.RData' | ||
|
||
function remove_spaces (){ | ||
mv "${1}" "${1// /_}" | ||
} | ||
# make the function available as a command so find can use it. | ||
export -f remove_spaces | ||
|
||
function remove_spaces_ext (){ | ||
if [ -z "$1" ] | ||
then | ||
echo "-- removing spaces on \"${DEFAULT_SPACES}\" files -- " | ||
else | ||
echo "-- removing spaces on \"${1}\" files -- " | ||
fi | ||
|
||
extension=${1-$DEFAULT_SPACES} | ||
|
||
FILES_spaced_num=$(find ./ -type f -iname '* *.'"${extension}" | wc -l) | ||
find ./ -type f -iname '*\ *.'"${extension}" -exec bash -c 'remove_spaces "{}"' \; | ||
# if you try to do this as a loop read: | ||
# http://mywiki.wooledge.org/BashPitfalls#for_i_in_.24.28ls_.2A.mp3.29 | ||
|
||
echo "-- converted ${FILES_spaced_num} files --" | ||
} | ||
|
||
|
||
#============================================================ | ||
# remove spaces from file names, otherwise xargs won't parallelise | ||
#============================================================ | ||
remove_spaces_ext | ||
|
||
#============================================================ | ||
# Break files into smaller chunks in parallel | ||
# - find the files, sort them by size (%k) | ||
# - extract the file names and run break_into 4 at a time | ||
# => filename.xml_xx.xml; where xx is a non padded number | ||
#============================================================ | ||
find ./ -type f -iname '*.xml' -printf "%k %p\n" | sort -nr \ | ||
| awk '{print $2}' | xargs -n1 -P 4 -I % ./break_into.sh % 3 | ||
|
||
#============================================================ | ||
# Convert each portion to ccdata | ||
#============================================================ | ||
find ./ -type f -iname '*.partxml' | xargs -n1 -P 4 ./extract_data.r | ||
|
||
#============================================================ | ||
# Combine all the files | ||
#============================================================ | ||
./combine_data.r ${allPatients} | ||
|
||
#============================================================ | ||
# Anonymise data removing timestamp | ||
#============================================================ | ||
./untimeit.r ${allPatients} ${allPatients_untime} | ||
|
||
echo "Files ${allPatients} and ${allPatients_untime} created." |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/Rscript | ||
|
||
library(ccdata) | ||
|
||
args = commandArgs(trailingOnly=TRUE) | ||
|
||
load(args[1]) | ||
ccd <- reindexRecord(ccd) | ||
ccd <- deltaTime(ccd, anonymised=T) | ||
ccd <- uniquePatients(ccd) | ||
ccd_delta_num <- ccd | ||
save(ccd_delta_num, file=args[2]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters