diff --git a/src/thematic_analysis/circos_AI.R b/src/thematic_analysis/circos_AI.R index a3fb182b41e4ded3628323e15676e241a0cdc0df..b8118695e0fb2aa144e8095053a79a7fd8a21fc3 100755 --- a/src/thematic_analysis/circos_AI.R +++ b/src/thematic_analysis/circos_AI.R @@ -105,7 +105,6 @@ calculate.relative.big.gap = function(padiweb.links.csv.filepath, healthmap.link # ######################################################################## prepare.input.for.chord.diagram = function(events.filepath, events.adjusted.filepath, links.filepath, year.of.interest, countries.of.interest, time.interval.col.name){ - df = read.csv(file=events.filepath, sep=";", header=T, check.names=F, stringsAsFactors=F) #df[,c(time.interval.col.name)] = df[,c(time.interval.col.name)] + 1 # because it starts from 0 time_interval_values = sapply(df[,c(time.interval.col.name)], function(x) unlist(strsplit(x, "_"))[1]) # we remove the year value @@ -115,6 +114,7 @@ prepare.input.for.chord.diagram = function(events.filepath, events.adjusted.file df[which(df[,"disease subtype"] == ""),"disease subtype"] = paste0(df[which(df[,"disease subtype"] == ""),"disease"], "-unknown") df[which(df[,"host subtype"] == ""),"host subtype"] = paste0(df[which(df[,"host subtype"] == ""),"host"], "-unknown") + # ================================================================ # ====================================================== @@ -131,7 +131,9 @@ prepare.input.for.chord.diagram = function(events.filepath, events.adjusted.file df = df[which(grepl("AI", df[,"disease"], fixed = TRUE)),] df = df[which(df[,"host"] == "bird"),] + df = df[order(df[,"country"]),] + if(!is.na(year.of.interest)) df = df[which(df[,"year"] == year.of.interest),] @@ -141,6 +143,7 @@ prepare.input.for.chord.diagram = function(events.filepath, events.adjusted.file df[,"disease"] = "AI" + # ================================================================ df1 = df[,c("region","disease subtype","country","disease",time.interval.col.name)] @@ -415,12 +418,14 @@ plot.chord.diagram.for.platforms <- function(padiweb.events.filepath, promed.eve create.chord.diagram(empresi.events.adjusted.filepath, empresi.links.filepath, empresi.output.filepath, colors.for.group, small.gap, big.gap, year.of.interest, time.interval.col.name) + print("padiweb vs promed") + # ============== # padiweb vs promed # ============== padiweb.output.filepath = file.path(out.padiweb.promed.folder, paste0("padiweb_events_",year.of.interest,".pdf")) - small.gap = 0.5 - big.gap = 4 # I know that there are a lot of entries for padiweb, so I put a small value of 'big.gap' for this plot + small.gap = 4 + big.gap = 40 # I know that there are a lot of entries for padiweb, so I put a small value of 'big.gap' for this plot create.chord.diagram(padiweb.events.adjusted.filepath, padiweb.links.filepath, padiweb.output.filepath, colors.for.group, small.gap, big.gap, year.of.interest, time.interval.col.name) promed.output.filepath = file.path(out.padiweb.promed.folder, paste0("promed_events_",year.of.interest,".pdf")) @@ -428,16 +433,17 @@ plot.chord.diagram.for.platforms <- function(padiweb.events.filepath, promed.eve ## Note that, small.gap should be the same for both cases rel.gap = calculate.relative.big.gap(padiweb.links.filepath, promed.links.filepath, small.gap, big.gap) big.gap = rel.gap - create.chord.diagram(promed.events.adjusted.filepath, promed.links.filepath, promed.output.filepath, colors.for.group, small.gap, big.gap, year.of.interest, time.interval.col.name) - + if(big.gap>0) + create.chord.diagram(promed.events.adjusted.filepath, promed.links.filepath, promed.output.filepath, colors.for.group, small.gap, big.gap, year.of.interest, time.interval.col.name) + print("empres-i vs padiweb") # ============== # empres-i vs padiweb # ============== empresi.output.filepath = file.path(out.padiweb.empresi.folder, paste0("empres-i_events_",year.of.interest,".pdf")) - small.gap = 0.5 - big.gap = 4 + small.gap = 4 + big.gap = 40 create.chord.diagram(empresi.events.adjusted.filepath, empresi.links.filepath, empresi.output.filepath, colors.for.group, small.gap, big.gap, year.of.interest, time.interval.col.name) padiweb.output.filepath = file.path(out.padiweb.empresi.folder, paste0("padiweb_events_",year.of.interest,".pdf")) @@ -445,16 +451,17 @@ plot.chord.diagram.for.platforms <- function(padiweb.events.filepath, promed.eve ## Note that, small.gap should be the same for both cases rel.gap = calculate.relative.big.gap(empresi.links.filepath, padiweb.links.filepath, small.gap, big.gap) big.gap = rel.gap - create.chord.diagram(padiweb.events.adjusted.filepath, padiweb.links.filepath, padiweb.output.filepath, colors.for.group, small.gap, big.gap, year.of.interest, time.interval.col.name) - + if(big.gap>0) + create.chord.diagram(padiweb.events.adjusted.filepath, padiweb.links.filepath, padiweb.output.filepath, colors.for.group, small.gap, big.gap, year.of.interest, time.interval.col.name) + print("empres-i vs promed") # ============== # empres-i vs promed # ============== empresi.output.filepath = file.path(out.promed.empresi.folder, paste0("empres-i_events_",year.of.interest,".pdf")) - small.gap = 0.5 - big.gap = 4 + small.gap = 4 + big.gap = 40 create.chord.diagram(empresi.events.adjusted.filepath, empresi.links.filepath, empresi.output.filepath, colors.for.group, small.gap, big.gap, year.of.interest, time.interval.col.name) promed.output.filepath = file.path(out.promed.empresi.folder, paste0("promed_events_",year.of.interest,".pdf")) @@ -462,7 +469,8 @@ plot.chord.diagram.for.platforms <- function(padiweb.events.filepath, promed.eve ## Note that, small.gap should be the same for both cases rel.gap = calculate.relative.big.gap(empresi.links.filepath, promed.links.filepath, small.gap, big.gap) big.gap = rel.gap - create.chord.diagram(promed.events.adjusted.filepath, promed.links.filepath, promed.output.filepath, colors.for.group, small.gap, big.gap, year.of.interest, time.interval.col.name) + if(big.gap>0) + create.chord.diagram(promed.events.adjusted.filepath, promed.links.filepath, promed.output.filepath, colors.for.group, small.gap, big.gap, year.of.interest, time.interval.col.name) }