Documentation
¶
Index ¶
- Constants
- Variables
- func AgeAtDiagnosis(p *Patient, DID int) int
- func AgeAtEOI(p *Patient) int
- func ClusterTrajectories(exp *Experiment, granularities []int, path string) error
- func CompactDiagnoses(p *Patient)
- func DiagnosisDateSmallerThan(d1, d2 DiagnosisDate) bool
- func DiagnosisDateToFloat(d DiagnosisDate) float64
- func LogTrajectory(t *Trajectory, exp *Experiment)
- func MakeDxDPatients(size int) [][][]*Patient
- func MakeDxDRR(size int) [][]float64
- func Mcl(mciFilePath string, granularity int) error
- func McxDump(clusterFileName string, tabFileName string, outFileName string, ...) error
- func McxLoadAbc(abcFilePath string, tabFilePath string, mciFilePath string) error
- func MetricsFromTrajectories(trajectories []*Trajectory) (float64, float64, float64, float64, int, int)
- func ParseTriNetXData(name, patientFile, diagnosisFile, diagnosisInfoFile, treatmentInfoFile string, ...) (*Experiment, *PatientMap)
- func ParsetTriNetXTumorData(fileName string) map[string][]*TumorInfo
- func PrintClusteredTrajectoriesToFile(exp *Experiment, name string)
- func PrintClustersToCSVFiles(exp *Experiment, pName, cName string)
- func Run(args *ExperimentParams) (err error)
- func SorensenDiceTrajectory(t1, t2 *Trajectory) float64
- func SortDiagnoses(p *Patient)
- func SzymkiewiczSimpsonTrajectory(t1, t2 *Trajectory) float64
- func TriNetXEventOfInterest(icd10ID string) bool
- type AnalysisMaps
- type Cohort
- type Diagnosis
- type DiagnosisDate
- type Experiment
- func (exp *Experiment) BuildTrajectories(minPatients, maxLength, minLength int, minTime, maxTime, minRR float64, ...) []*Trajectory
- func (exp *Experiment) InitRR(minTime, maxTime float64, iter int)
- func (exp *Experiment) LoadDxDPatients(pMap *PatientMap, path string)
- func (exp *Experiment) LoadRRMatrix(path string)
- func (exp *Experiment) PrintTrajectoriesToFile(path string)
- func (exp *Experiment) SaveDxDPatients(path string)
- func (exp *Experiment) SaveRRMatrix(path string)
- type ExperimentParams
- type Icd10Entry
- type Pair
- type Patient
- type PatientFilter
- func AboveSeventyAggregator() PatientFilter
- func EOIAfterFilter() PatientFilter
- func EOIBeforeFilter() PatientFilter
- func EOIFilter(test func(d1, d2 DiagnosisDate) bool) PatientFilter
- func FemaleFilter() PatientFilter
- func GetPatientFilter(s string, tinfo map[string][]*TumorInfo) PatientFilter
- func GetPatientFilters(filters string, tinfo map[string][]*TumorInfo) []PatientFilter
- func LessThanSeventyAggregator() PatientFilter
- func M0StageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
- func M1StageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
- func MIBCAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
- func MUCAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
- func MaleFilter() PatientFilter
- func N0StageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
- func N1StageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
- func N2StageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
- func N3StageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
- func NMIBCAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
- func SexFilter(sex int) PatientFilter
- func T1StageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
- func T2StageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
- func T3StageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
- func T4StageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
- func TaStageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
- func TisStageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
- type PatientMap
- type Trajectory
- type TrajectoryFilter
- type TreatmentInfo
- type TumorInfo
Constants ¶
const ( Male = 0 Female = 1 )
Variables ¶
var InitializeIcd10AnalysisMaps = initializeIcd10AnalysisMaps
var InitializeIcd10AnalysisMapsFromXML = initializeIcd10AnalysisMapsFromXML
var InitializeIcd10NameMap = initializeIcd10NameMap
var ParseIcd10HierarchyFromXml = parseIcd10HierarchyFromXml
var ParseIcd9ToIcd10Mapping = parseIcd9ToIcd10Mapping
var ParseTriNetXPatientData = parseTriNetXPatientData
var ParseTrinetXPatientDiagnoses = parseTrinetXPatientDiagnoses
var PrintIcd10Hierarchy = printIcd10Hierarchy
var PrintIcd10NameMap = printIcd10NameMap
Functions ¶
func AgeAtDiagnosis ¶
AgeAtDiagnosis calculates the age of a patient at a specific diagnosis
func AgeAtEOI ¶
AgeAtEOI calculates the age of a patient at the event of interest (e.g. cancer diagnosis)
func ClusterTrajectories ¶
func ClusterTrajectories(exp *Experiment, granularities []int, path string) error
ClusterTrajectories performs clustering of the trajectories that have been calculated for a given experiment. It does a pairwise comparison of all trajectories by calculating the jaccard similarity coefficients. Subsequently, MCL clustering is used to group the trajectories by jaccard similarity into clusters.
func CompactDiagnoses ¶
func CompactDiagnoses(p *Patient)
CompactDiagnoses makes a sorted diagnosis list contain unique diagnoses for a patient. Want to avoid over counting diagnoses.
func DiagnosisDateSmallerThan ¶
func DiagnosisDateSmallerThan(d1, d2 DiagnosisDate) bool
func DiagnosisDateToFloat ¶
func DiagnosisDateToFloat(d DiagnosisDate) float64
DiagnosisDateToFloat converts a diagnosis date to a floating point number.
func LogTrajectory ¶
func LogTrajectory(t *Trajectory, exp *Experiment)
LogTrajectory prints a trajectory to standard output.
func MakeDxDPatients ¶
MakeDxDPatients makes a diagnosis by diagnosis-sized matrix for storing the list of patients for each possible diagnosis pair.
func MakeDxDRR ¶
MakeDxDRR makes a diagnosis by diagnosis-sized matrix for storing the relative risk score for each possible diagnosis pair.
func McxLoadAbc ¶
McxLoadAbc calls the mcxload binary for an abc-file.
func MetricsFromTrajectories ¶
func MetricsFromTrajectories(trajectories []*Trajectory) (float64, float64, float64, float64, int, int)
MetricsFromTrajectories computes: * mean age + standard deviation + median age for patients in the trajectories. Patients can occur in different trajectories. For mean age + sd + median, they will be counted as separate instances. * #patients per age category (normalized in percentages, not absolute numbers). Patients that occr in different trajectories will be counted as separate instances for these age Categories. * #males, #females * mean survival time after event of interest
func ParseTriNetXData ¶
func ParseTriNetXData(name, patientFile, diagnosisFile, diagnosisInfoFile, treatmentInfoFile string, nofCohortAges, level int, minYears, maxYears float64, icd9ToIcd10File string, filters []PatientFilter) (*Experiment, *PatientMap)
func ParsetTriNetXTumorData ¶
ParsetTriNetXTumorData parses the tumor data from a csv file and returns a map PIDString -> []*TumorInfo.
func PrintClusteredTrajectoriesToFile ¶
func PrintClusteredTrajectoriesToFile(exp *Experiment, name string)
PrintClusteredTrajectoriesToFile plots the trajectories of an experiment to a tab file, including for each trajectory information about the cluster a trajectory belongs to. For each trajectory it prints 3 lines: - A line with the cluster ID and the trajectory ID: CID: \tab nr \tab TID: \tab nr. - A list of medical terms for the diagnoses: term1 \tab term2 ...\tab termn. - A list of patient numbers for the transitions between diagnosis pairs: nr1->2 \tab nr2->3 ...\tab nrn-1->n.
func PrintClustersToCSVFiles ¶
func PrintClustersToCSVFiles(exp *Experiment, pName, cName string)
PrintClustersToCSVFiles prints the experiment clusters to a CSV file. It creates two output files: - A CSV file with patient information. The header is: PID,AgeEOI,Sex,PIDString. This represents: patient analysis id, age at which the event of interest occurred, sex, and the TriNetX patient id. - A CSV file with cluster information. The header is: PID,CID,TID,Age. This represents: patient id, cluster id, trajectory id, and age of the patient when matching the trajectory.
func Run ¶
func Run(args *ExperimentParams) (err error)
Run runs a TriNetX experiment with the given parameters.
func SorensenDiceTrajectory ¶
func SorensenDiceTrajectory(t1, t2 *Trajectory) float64
SorensenDiceTrajectory computes the SorensenDice similarity coefficient for two given trajectories.
func SortDiagnoses ¶
func SortDiagnoses(p *Patient)
SortDiagnoses modifies a given patient's list of diagnoses to be ordered by date.
func SzymkiewiczSimpsonTrajectory ¶
func SzymkiewiczSimpsonTrajectory(t1, t2 *Trajectory) float64
SzymkiewiczSimpsonTrajectory computes the Szymkiewicz-Simpson similarity coefficient for two given trajectories.
func TriNetXEventOfInterest ¶
TriNetXEventOfInterest checks if the ICD10 code is related to bladder cancer
Types ¶
type AnalysisMaps ¶
type AnalysisMaps interface {
GetICDCode(did int) string
// contains filtered or unexported methods
}
AnalysisMaps represent maps extracted from the input that map analysis IDs onto medical terms and vice versa. This is an interface that defines several methods. getICDCode returns for a did the original id in the input for the diagnostic event. fillInPatientDiagnoses creates for a given diagnosis identifier from the input a Diagnosis object and adds it to a patient's list of diagnoses.
type Cohort ¶
type Cohort struct {
AgeGroup, Sex, Region, NofPatients, NofDiagnoses int
DCtr []int //counts nr of patients per DID
DPatients [][]*Patient //contains a list of patients per DID
Patients []*Patient //the patients in this cohort
}
Cohort represents a specific group of patients from the population stratified by age, sex, and region. The population is divided into male and female cohorts. Those cohorts are in turn split into cohorts depending on an age range, e.g. this could be one for each possible age range apart by 10 years: [0-10], [10-20],[20-30]...[100-120].
func InitCohorts ¶
func InitCohorts(patients *PatientMap, nofAgegroups, nofRegions, nofDiagnosisCodes int) []*Cohort
InitCohorts creates cohorts + initializes them with the counts for each diagnosis + patients per diagnosis
func MergeCohorts ¶
MergeCohorts returns a single cohort that merges a list of input cohorts. The goal is to obtain a merged list of patients, a merged patient total, and a merged disease total.
type Diagnosis ¶
type Diagnosis struct {
PID, DID int
Date DiagnosisDate
Icd10 Icd10Entry
}
Diagnosis represents a diagnosis for a patient.
type DiagnosisDate ¶
type DiagnosisDate struct {
Year, Month, Day int
}
DiagnosisDate represents the date of a diagnosis, with fields for representing the year, month, and day of diagnosis.
type Experiment ¶
type Experiment struct {
NofAgeGroups, NofRegions, Level, NofDiagnosisCodes int
DxDRR [][]float64 // per disease pair, relative risk score (RR)
DxDPatients [][][]*Patient // per disease pair, all patients diagnosed
DPatients [][]*Patient // per disease, all patients diagnosed
Cohorts []*Cohort // cohorts in the experiment
Name string // Name of the experiment, for printing
Icd10Map map[int]Icd10Entry // maps diagnosis ID to Icd10Entry
Trajectories []*Trajectory // a list of computed trajectories
Pairs []*Pair // a list of all selected pairs that are used to compute trajectories
IdMap map[int]string // maps the analysis DID to the original diagnostic ID used in the input data
MCtr, FCtr int // counters for counting nr of males,females,patients
}
Experiment contains the inputs and outputs for calculating diagnosis trajectories for a specific patient population.
func (*Experiment) BuildTrajectories ¶
func (exp *Experiment) BuildTrajectories(minPatients, maxLength, minLength int, minTime, maxTime, minRR float64, filters []TrajectoryFilter) []*Trajectory
BuildTrajectories calculates the trajectories for an experiment. The trajectories are constrained by: a minimum number of patients in the trajectory (minPatients), a maximum number of diagnoses in the trajectory (maxLength), a minimum number of diagnoses in the trajectory (minLength), a minimum RR for each diagnosis transition (minRR), and a list of filters.
func (*Experiment) InitRR ¶
func (exp *Experiment) InitRR(minTime, maxTime float64, iter int)
InitRR computes the relative risk ratios for each possible diagnosis pair in an experiment. It takes into account the minimum and maximum time between diagnoses (minTime and maxTime). It is an iterative algorithm that runs for a given number of iterations (iter). With iter = 400, the calculated p-values are within 0.05 of the true p-values and with iter = 10000 they are within 0.01 of the true p-values. The relative risk ratios are calculated in parallel for all possible diagnosis pairs.
func (*Experiment) LoadDxDPatients ¶
func (exp *Experiment) LoadDxDPatients(pMap *PatientMap, path string)
LoadDxDPatients loads the DxD patients from a file created during a previous run. It takes as parameters the experiment (exp), the patient map where to look up patient objects parsed from the input (pMap), and the file Name (path). The function side effects the experiment's DxDPatients slice. It uses the pMap to match concrete patient objects with IDs stored in the file to be able to fill the patients for each pair of diagnoses.
func (*Experiment) LoadRRMatrix ¶
func (exp *Experiment) LoadRRMatrix(path string)
LoadRRMatrix loads an RR matrix from file and stores it in the given experiment. This file was created from a previous run. This can be used instead of initializeRelativeRiskRatiosParallel
func (*Experiment) PrintTrajectoriesToFile ¶
func (exp *Experiment) PrintTrajectoriesToFile(path string)
PrintTrajectoriesToFile outputs an experiment's calculated trajectories to file in multiple formats: - A tab file containing trajectories as lists of medical terms and lists of numbers of patients for each transition - A tab file containing all disease pairs and their relative risk scores (medical terms + float for RR) - A GML file with one graph representing all trajectories - A GML file where each trajectory is represented as an individual subgraph
func (*Experiment) SaveDxDPatients ¶
func (exp *Experiment) SaveDxDPatients(path string)
SaveDxDPatients saves per disease the PIDs that are diagnosed with this disease
func (*Experiment) SaveRRMatrix ¶
func (exp *Experiment) SaveRRMatrix(path string)
SaveRRMatrix stores the RR matrix calculated for the given experiment. The diagnosis pairs from the matrix are stored line per line as follows: medical Name 1, medical Name 2, RR.
type ExperimentParams ¶
type ExperimentParams struct {
// required parameters
Name string
PatientInfo string // path to the file with patient information (ID, gender," + birthyear, etc)
DiagnosisInfo string // path to the file with diagnosis information (ID,descriptor, hierarchy, etc)
PatientDiagnoses string // path to the file with patient diagnoses.
OutputPath string // path where output files are written to.
// optional parameters
NofAgeGroups int
Lvl int
MaxYears float64
MinYears float64
MinPatients int
MaxTrajectoryLength int
MinTrajectoryLength int
ICD9ToICD10File string
Cluster bool
ClusterGranularities string
Iter int
RR float64
SaveRR string
LoadRR string
PFilters string
TFilters string
TumorInfo string
TreatmentInfo string
NrOfThreads int
}
type Icd10Entry ¶
type Icd10Entry struct {
Name string // medical Name for a DID in ICD10 encoding
Categories [6]string // the names of the ICD10 encoding higher and lower in the hierarchy.
Level int // the ICD10 hierarchy Level of this Name.
}
Icd10Entry is a struct for containing a medical Name + Level + the Categories of a DID in ICD10 encoding.
type Pair ¶
type Pair struct {
First, Second int
}
Pair is a struct for representing a diagnosis pair. It simply stores two diagnosis codes.
type Patient ¶
type Patient struct {
PID int // analysis ID
PIDString string // ID from TriNetX
YOB int // year of birth
CohortAge int // age range a patient belongs to
Sex int // 0 = male, 1 = female
Diagnoses []*Diagnosis // list of patient's diagnoses, sorted by date <, unique diagnosis per date
EOIDate *DiagnosisDate // Event of interest date, e.g. day of cancer diagnosis
DeathDate *DiagnosisDate // Date of death
Region int // Region where the patient lives
}
Patient represents patient information.
func AppendPatient ¶
AppendPatient appends a patient to a slice of patients, unless that patient is already a member of that slice.
func GetPatient ¶
func GetPatient(pidString string, patients *PatientMap) (*Patient, bool)
GetPatient retrieves from a patient map the patient object associated with a given patient ID. The patient ID is passed as a string and refers to the PID that occurs in the input.
func (*Patient) AddDiagnosis ¶
AddDiagnosis appends a diagnosis to a patient's list of diagnoses.
type PatientFilter ¶
PatientFilter prescribes a function type for implementing filters on TriNetX patients, to be able to calculate trajectories for specific cohorts. E.g. male patients, patients <70 years, patients with specific cancer stage, etc.
func AboveSeventyAggregator ¶
func AboveSeventyAggregator() PatientFilter
AboveSeventyAggregator collects all patients above a specific age.
func EOIAfterFilter ¶
func EOIAfterFilter() PatientFilter
EOIAfterFilter removes all diagnoses after the event of interest date
func EOIBeforeFilter ¶
func EOIBeforeFilter() PatientFilter
EOIBeforeFilter removes all diagnoses before the event of interest date
func EOIFilter ¶
func EOIFilter(test func(d1, d2 DiagnosisDate) bool) PatientFilter
EOIFilter removes all diagnoses for patients that satisfy a given predicate
func GetPatientFilter ¶
func GetPatientFilter(s string, tinfo map[string][]*TumorInfo) PatientFilter
func GetPatientFilters ¶
func GetPatientFilters(filters string, tinfo map[string][]*TumorInfo) []PatientFilter
func LessThanSeventyAggregator ¶
func LessThanSeventyAggregator() PatientFilter
LessThanSeventyAggregator collects all patients below a specific age.
func M0StageAggregator ¶
func M0StageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
M0StageAggregator collects patients with stage M0 bladder cancer.
func M1StageAggregator ¶
func M1StageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
M1StageAggregator collects patients with stage M1 bladder cancer.
func MIBCAggregator ¶
func MIBCAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
MIBCAggregator checks all patients if they match the cancer criteria to be defined as muscle invasive bladder cancer patients.
func MUCAggregator ¶
func MUCAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
MUCAggregator checks all patients if they match the cancer criteria to be defined as metastisized bladder cancer patients.
func N0StageAggregator ¶
func N0StageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
N0StageAggregator collects patients with stage N0 bladder cancer.
func N1StageAggregator ¶
func N1StageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
N1StageAggregator collects patients with stage N1 bladder cancer.
func N2StageAggregator ¶
func N2StageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
N2StageAggregator collects patients with stage N2 bladder cancer.
func N3StageAggregator ¶
func N3StageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
N3StageAggregator collects patients with stage N0 bladder cancer.
func NMIBCAggregator ¶
func NMIBCAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
NMIBCAggregator checks all patients if they match the cancer criteria to be defined as non muscle invasive bladder cancer patients.
func SexFilter ¶
func SexFilter(sex int) PatientFilter
SexFilter removes all patients of the given sex.
func T1StageAggregator ¶
func T1StageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
T1StageAggregator collects patients with stage T1 bladder cancer.
func T2StageAggregator ¶
func T2StageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
T2StageAggregator collects patients with stage T2 bladder cancer.
func T3StageAggregator ¶
func T3StageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
T3StageAggregator collects patients with stage T3 bladder cancer.
func T4StageAggregator ¶
func T4StageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
T4StageAggregator collects patients with stage T4 bladder cancer.
func TaStageAggregator ¶
func TaStageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
TaStageAggregator collects patients with stage Ta bladder cancer.
func TisStageAggregator ¶
func TisStageAggregator(tinfoMap map[string][]*TumorInfo) PatientFilter
TisStageAggregator collects patients with stage Tis bladder cancer.
type PatientMap ¶
type PatientMap struct {
PIDStringMap map[string]int // maps patient string id onto an int PID
Ctr int // total nr of patients parsed, also used for creating PIDs
PIDMap map[int]*Patient // maps PID onto a patient object that contain YOB, sex, age group, etc
// optional info for logging
MaleCtr int
FemaleCtr int
}
PatientMap contains all patient information parsed from the input.
func ApplyPatientFilter ¶
func ApplyPatientFilter(filter PatientFilter, pMap *PatientMap) *PatientMap
func ApplyPatientFilters ¶
func ApplyPatientFilters(filters []PatientFilter, pMap *PatientMap) *PatientMap
type Trajectory ¶
type Trajectory struct {
Diagnoses []int // A list of diagnosis codes that represent the trajectory
PatientNumbers []int // A list with nr of patients for each transition in the trajectory
Patients [][]*Patient // A list of patients with the given trajectory
TrajMap map[*Patient]int // Maps patient IDs onto a diagnosis index for trajectory tracking
ID int // An analysis id
Cluster int // A cluster ID to which this trajectory is assigned to
}
Trajectory holds all data relevant to a disease trajectory.
type TrajectoryFilter ¶
type TrajectoryFilter func(t *Trajectory) bool
TrajectoryFilter is a type to define a trajectory filter function. Such filters take as input a trajectory and must return a bool as output that determines if a trajectory passes a filter or not.
func BladderCancerTrajectoryFilter ¶
func BladderCancerTrajectoryFilter(exp *Experiment) TrajectoryFilter
BladderCancerTrajectoryFilter filters trajectories down to trajectories with at least one diagnosis that is related to bladder cancer specifically, cf. ICD10 Categories C67,C77,C78,C79 or procedures such as MVAC chemo, IVT treatment, or radical cystectomy.
func CancerTrajectoryFilter ¶
func CancerTrajectoryFilter(exp *Experiment) TrajectoryFilter
CancerTrajectoryFilter filters trajectories down to trajectories that contain at least one diagnosis code that is considered to be cancer-related, e.g. containing the word "neoplasm".
func GetTrajectoryFilter ¶
func GetTrajectoryFilter(filter string, exp *Experiment) TrajectoryFilter
func GetTrajectoryFilters ¶
func GetTrajectoryFilters(filters string, exp *Experiment) []TrajectoryFilter
type TreatmentInfo ¶
type TreatmentInfo struct {
RCDate *DiagnosisDate //Date of radical cystectomy
MVACDate *DiagnosisDate //Date of MVAC chemotherapy
IVTDate *DiagnosisDate //Date of intravesical therapy
}
TreatmentInfo implements a structure for storing the dates of certain bladder cancer treatments.
type TumorInfo ¶
type TumorInfo struct {
TStage, NStage, MStage, Stage string
Date DiagnosisDate
}
TumorInfo is a struct for storing bladder cancer tumor information concerning: tumor size, tumor lymph nodes, tumor metastasis