Skip to content

Commit

Permalink
additional plotting, problems with reshape2, new version of icu has b…
Browse files Browse the repository at this point in the history
…roken the library
  • Loading branch information
josura committed Jul 13, 2023
1 parent f3c483f commit 7b0ca6a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
10 changes: 7 additions & 3 deletions scripts/R/plotTimeSeriesToyExample.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ library(ggplot2)

timeSeries.t0 <- read.csv("/home/josura/Projects/ccc/c2c-sepia/outputsTimeSeries/t2_outputAll.tsv",sep = "\t",header = TRUE)

library(reshape2)
library(tidyverse)


x <- timeSeries.t0[, 1]
y <- timeSeries.t0[, (ncol(timeSeries.t0)-11):ncol(timeSeries.t0)]

Expand All @@ -12,14 +14,16 @@ interesting.list <- c("v.in.t3","v.in.t1","v.out.t3","v.out.t1","v.out.t2")
y.int <- timeSeries.t0[, interesting.list]

# Combine x and y into a new dataframe
df_new <- data.frame(x = rep(x, ncol(y)), c(y))
df_new <- data.frame(x = rep(x, ncol(y)), y)

# Convert y columns into a single column
df_new <- melt(df_new, id.vars = "x")
df_new <- df_new %>%
pivot_longer(cols = starts_with("v."), names_to = "variable", values_to = "value")

# Plot the matrix of scatter plots
ggplot(df_new, aes(x = x, y = value, color = variable)) +
geom_point() +
labs(x = "X Axis", y = "Y Axis") +
scale_color_discrete(name = "Y Variables") +
facet_wrap(~ variable, ncol = 3) # Adjust the number of columns as needed

33 changes: 33 additions & 0 deletions scripts/R/testingComputation.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
library(MASS)

matriceTest <- t(matrix(c(0,0.2,0.4,0.5,0,0,0,0,
0.2,0,0.4,0.5,0,0,1,0,
0.3,0.2,0,0.5,0,0,0,0,
0.4,0.2,0.4,0,0,0,0,1,
0,1,0,0,0,0,0,0,
1,1,1,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0),nrow=8))

normalizedMatrix <- apply(t(matriceTest), 2, function(col) {
if (sum(col) != 0) {
col / sum(col)
} else {
rep(0, length(col))
}
})


# Creating the identity matrix with the same dimensions as normalizedMatrix
identityMatrix <- diag(nrow(normalizedMatrix))

# Subtracting the transpose of the normalizedMatrix from the identity matrix
resultMatrix <- identityMatrix - normalizedMatrix

inverted <- ginv(resultMatrix)

input <- c(1,1,0.1,2,0,0,0,0)

perturbation <- inverted %*% input

perturvation.conserverd <- inverted %*% input - (input/2)

0 comments on commit 7b0ca6a

Please sign in to comment.