# Dimension Reduction on Data with both Spatial and Non-Spatial Variables to Train a Logistic Regressor for Cross Sectional Time Series Data

I need some help on how to process and analyse a study of mine. I'm running a study on mice to look at the effect of diet on cells over a series of time. My mice are divided into two groups, one group gets a high fat diet for the duration of the timecourse, the other gets a control diet. I look at multiple cells per mouse per timepoint, with the cells being different between timepoints so my experimental setup looks something like this, where each row represents a distinct cell, but cells belong to timepoint, diet, and animal groups, and I have some measures of the cell shapes

#>    Animal     Diet Timepoint Cell   Perimeter   CellArea
#> 1       1 High Fat         1    1 0.017101471 2.25888213
#> 2       1 High Fat         1    2 1.133146728 0.61595298
#> 3       1 High Fat         2    3 0.088018475 0.03012002
#> 4       1 High Fat         2    4 1.412794322 0.51740375
#> 5       1 High Fat         3    5 0.535036459 1.57801146
#> 6       1 High Fat         3    6 0.001141126 1.91101794
#> 7       2  Control         1    7 1.168582551 0.08722967
#> 8       2  Control         1    8 0.425678758 0.08046728
#> 9       2  Control         2    9 0.298191708 0.50043838
#> 10      2  Control         2   10 0.209900259 0.14803764
#> 11      2  Control         3   11 0.117915604 1.21472268
#> 12      2  Control         3   12 0.653433272 2.02029402


I also have data for each cell where I measure the number of processes the cell has at different distances from its centre, which looks like this:

#>    Animal     Diet Timepoint Cell Distance  Processes
#> 1       1 High Fat         1    1      1         2
#> 2       1 High Fat         1    1      2         1
#> 3       1 High Fat         2    2      1         1
#> 4       1 High Fat         2    2      2         1
#> 5       1 High Fat         3    3      1         2
#> 6       1 High Fat         3    3      2         1
#> 7       2  Control         1    4      1         2
#> 8       2  Control         1    4      2         1
#> 9       2  Control         2    5      1         1
#> 10      2  Control         2    5      2         1
#> 11      2  Control         3    6      1         1
#> 12      2  Control         3    6      2         1


Now what I'm trying to do is use the shape descriptor and process data for each cell to train a model on whether that cell is inflammed or not. This is based on a dataset I've collected where I inject some mice with LPS to induce inflammation. In order to combine the process and shape descriptor data into a single data frame, I have it structured like this:

#>    Animal Inflammed Cell Perimeter   CellArea ProcessesRad1 ProcessesRad2
#> 1       1       Yes    1 0.7511064 0.80098259             1             2
#> 2       1       Yes    2 0.2237304 1.63238312             1             1
#> 3       1       Yes    3 0.4265940 0.90665658             3             1
#> 4       1       Yes    4 0.4050261 0.95661363             1             1
#> 5       1       Yes    5 1.0544229 1.22095474             1             1
#> 6       1       Yes    6 0.5587604 0.32316867             2             3
#> 7       2        No    7 0.2254080 0.03443459             1             2
#> 8       2        No    8 0.7026805 0.23408001             1             1
#> 9       2        No    9 0.6591998 2.22043828             3             1
#> 10      2        No   10 0.4933573 0.81072003             1             3
#> 11      2        No   11 0.4154093 0.77474702             1             1
#> 12      2        No   12 0.1180607 0.19600159             1             1


My plan is to find a way to run a PCA on data like this, where I have all the measures for each cell combined into a single matrix, since in realityI have many more measured variables. I then want to use some selection of the principal components to train a logistic regressor on whether the cell is inflammed or not. I want to use this trained model on my diet/timecourse data to look at whether there are significant effects of diet and timepoint on the probability that a cell would be classified as inflammed.

My first hurdle is about how to combine the two datasets and run a single PCA on that combined data. Is it reasonable to run a standard PCA on this data if I combine it like I have above? I know there are functional PCA techniques for looking at spatially oriented data, which I could apply to my process measurements, but I'm not sure how to go about a PCA on a matrix that has both my process and shape descriptor data together, or if I'm just overthinking it.

Is it possible to run two separate PCAs, one on my non-spatial, and one on my spatial data, then combine them somehow? Is that necessary?

The next problem will be how to approach the further analysis. To train the logistic regressor, my plan is to build a model with certain PCs from the inflammed/non inflammed data that allows me to distinguish between inflammed and non inflammed. I'm going to look into using mixed effects logistic regression to incorporate a random effect for animal in this model as well.

Once I've done this, my idea is to apply the PC weights taken from the inflammed/noninflammed data set, apply those to my diet/timepoint dataset, apply my inflammed/noninflammed logistic model to the diet/timepoint PCs, then look at the probabilities generated by that model, and see if they are influenced by diet or timepoint.

I apologize for the length of my question, but I'm coming at this from essentially a novice level where I have at most run ANOVAs or linear mixed models without digging into the details too much, and I'm in a lab where nobody else has any experience in this sort of approach. I'm working in R. Any help would be much appreciated, thanks.