Melanoma vs Seborreic_Keratosis
Loading data sets
op <- par(no.readonly = TRUE)
MelanomaFeatures <- read.csv("E:/SKINCCANCER/MatlabScripts/MelanomaLesionFeatures.csv", header=FALSE)
SeborrheicFeatures <- read.csv("E:/SKINCCANCER/MatlabScripts/SeborrheicLesionFeatures.csv", header=FALSE)
MelanomaControlFeatures <- read.csv("E:/SKINCCANCER/MatlabScripts/MelanomaControlFeatures.csv", header=FALSE)
SeborrheicControlFeatures <- read.csv("E:/SKINCCANCER/MatlabScripts/SeborrheicControlFeatures.csv", header=FALSE)
LesionFeatureNames <- read_excel("FeatureNames.xlsx")
ControlFeatureNames <- read_excel("FeatureNames.xlsx",sheet = "Control")
FeatureNames <- read_excel("FeatureNames.xlsx",sheet = "PerChannel")
colnames(MelanomaFeatures) <- LesionFeatureNames$FinalName
colnames(SeborrheicFeatures) <- LesionFeatureNames$FinalName
colnames(MelanomaControlFeatures) <- ControlFeatureNames$FinalName
colnames(SeborrheicControlFeatures) <- ControlFeatureNames$FinalName
sum(is.na(MelanomaFeatures))
sum(is.na(SeborrheicFeatures))
sum(is.na(MelanomaControlFeatures))
channel1 <- c(1:32)
channel2 <- c(33:64)
channel3 <- c(65:96)
MMelanomaFeatures <- ( MelanomaFeatures[,channel1] +
MelanomaFeatures[,channel2] +
MelanomaFeatures[,channel3] )/3.0
SMelanomaFeatures <- ( abs(MelanomaFeatures[,channel1] - MMelanomaFeatures) +
abs(MelanomaFeatures[,channel2] - MMelanomaFeatures) +
abs(MelanomaFeatures[,channel3] - MMelanomaFeatures) )/3.0
colnames(MMelanomaFeatures) <- paste("M",FeatureNames$Features,sep="")
colnames(SMelanomaFeatures) <- paste("S",FeatureNames$Features,sep="")
MelanomaFeatures <- cbind(MelanomaFeatures,SMelanomaFeatures/(0.001+abs(MMelanomaFeatures)))
MSeborrheicFeatures <- ( SeborrheicFeatures[,channel1] +
SeborrheicFeatures[,channel2] +
SeborrheicFeatures[,channel3] )/3.0
SSeborrheicFeatures <- (abs(SeborrheicFeatures[,channel1] - MSeborrheicFeatures) +
abs(SeborrheicFeatures[,channel2] - MSeborrheicFeatures) +
abs(SeborrheicFeatures[,channel3] - MSeborrheicFeatures))/3.0
colnames(MSeborrheicFeatures) <- paste("M",FeatureNames$Features,sep="")
colnames(SSeborrheicFeatures) <- paste("S",FeatureNames$Features,sep="")
SeborrheicFeatures <- cbind(SeborrheicFeatures,SSeborrheicFeatures/(0.001+abs(MSeborrheicFeatures)))
MMelanomaControlFeatures <- ( MelanomaControlFeatures[,channel1] +
MelanomaControlFeatures[,channel2] +
MelanomaControlFeatures[,channel3] )/3.0
SMelanomaControlFeatures <- (abs(MelanomaControlFeatures[,channel1] - MMelanomaControlFeatures) +
abs(MelanomaControlFeatures[,channel2] - MMelanomaControlFeatures) +
abs(MelanomaControlFeatures[,channel3] - MMelanomaControlFeatures))/3.0
colnames(MMelanomaControlFeatures) <- paste("M_C",FeatureNames$Features,sep="")
colnames(SMelanomaControlFeatures) <- paste("S_C",FeatureNames$Features,sep="")
MelanomaControlFeatures <- cbind(MelanomaControlFeatures,SMelanomaControlFeatures/(0.001+abs(MMelanomaControlFeatures)))
MSeborrheicControlFeatures <- ( SeborrheicControlFeatures[,channel1] +
SeborrheicControlFeatures[,channel2] +
SeborrheicControlFeatures[,channel3] )/3.0
SSeborrheicControlFeatures <- (abs(SeborrheicControlFeatures[,channel1] - MSeborrheicControlFeatures) +
abs(SeborrheicControlFeatures[,channel2] - MSeborrheicControlFeatures) +
abs(SeborrheicControlFeatures[,channel3] - MSeborrheicControlFeatures))/3.0
colnames(MSeborrheicControlFeatures) <- paste("M_C",FeatureNames$Features,sep="")
colnames(SSeborrheicControlFeatures) <- paste("S_C",FeatureNames$Features,sep="")
SeborrheicControlFeatures <- cbind(SeborrheicControlFeatures,
SSeborrheicControlFeatures/(0.001+abs(MSeborrheicControlFeatures)))
CtrDiff <- MelanomaFeatures[,1:ncol(MelanomaControlFeatures)] - MelanomaControlFeatures;
colnames(CtrDiff) <- colnames(MelanomaControlFeatures)
MelanomaFeatures <- cbind(MelanomaFeatures,CtrDiff)
CtrDiff <- SeborrheicFeatures[,1:ncol(MelanomaControlFeatures)] - SeborrheicControlFeatures;
colnames(CtrDiff) <- colnames(SeborrheicControlFeatures)
SeborrheicFeatures <- cbind(SeborrheicFeatures,CtrDiff)
MelanomaFeatures <- MelanomaFeatures[complete.cases(MelanomaFeatures),]
SeborrheicFeatures <- SeborrheicFeatures[complete.cases(SeborrheicFeatures),]
MelanomaFeatures$Class <- rep(1,nrow(MelanomaFeatures))
SeborrheicFeatures$Class <- rep(0,nrow(SeborrheicFeatures))
MelanomaSeborrheic <- rbind(MelanomaFeatures,SeborrheicFeatures)
table(MelanomaSeborrheic$Class)
The Heatmap
par(op)
par(mar=c(10,5,5,5))
boxplot(MelanomaSeborrheic,las=2,cex=0.5,cex.axis=0.5,main="Features")

par(op)
hm <- heatMaps(Outcome = "Class",
data = MelanomaSeborrheic,
title = "Heat Map:",Scale = TRUE,
hCluster = "col",cexRow = 0.75,cexCol = 0.35,srtCol = 45)

uks <- univariate_KS(MelanomaSeborrheic,"Class")
par(mar=c(5,15,5,5))
barplot(-log(1.0e-12+uks[1:20]),las=2,xlab="Log(pvalue)",cex.names = 0.65,main="Top Features",horiz=TRUE)

print(uks[1:20])
#> C_Blue_Red_Mean C_Blue_Red_Compactness
#> 0.000000e+00 0.000000e+00
#> C_Blue_Red_GradientRatios C_Green_Compactness
#> 0.000000e+00 2.864375e-14
#> C_Green_Mean C_Red_Green_Mean
#> 9.166001e-14 1.145750e-13
#> C_Blue_Red_Skewness C_Blue_Red_Fractal_Homogeneity
#> 2.243215e-11 4.889171e-11
#> L_Green_Energy_2 SHomogeneity_8
#> 4.889171e-11 1.341647e-10
#> C_Blue_Red_Gradient SEnergy_4
#> 1.341647e-10 2.103335e-10
#> S_CFractal_Correlation C_Red_Green_Fractal_Homogeneity
#> 3.182850e-10 3.440306e-10
#> SStandard_Deviation L_Green_Mean
#> 3.440306e-10 3.771648e-10
#> L_Green_90COV L_Blue_Red_Gradient
#> 3.961532e-10 4.024909e-10
#> C_Green_COV SMean
#> 1.079453e-09 1.746786e-09
par(op)
Learning Melanoma with KNN
cvKNN <- randomCV(MelanomaSeborrheic,"Class",
KNN_method,
trainFraction = 0.90,
repetitions = 100,
classSamplingType = "Pro",
featureSelectionFunction = univariate_KS,
featureSelection.control = list(pvalue=0.05,limit= -1),
kn=5
)
#> ..........10 Tested: 342 Avg. Selected: 158.8 Min Tests: 1 Max Tests: 4 Mean Tests: 1.549708 . MAD: 0.3074618
#> ..........20 Tested: 459 Avg. Selected: 157.1 Min Tests: 1 Max Tests: 6 Mean Tests: 2.309368 . MAD: 0.3129108
#> ..........30 Tested: 504 Avg. Selected: 157.2667 Min Tests: 1 Max Tests: 9 Mean Tests: 3.154762 . MAD: 0.3126754
#> ..........40 Tested: 515 Avg. Selected: 157.5 Min Tests: 1 Max Tests: 10 Mean Tests: 4.116505 . MAD: 0.3120033
#> ..........50 Tested: 520 Avg. Selected: 157.28 Min Tests: 1 Max Tests: 12 Mean Tests: 5.096154 . MAD: 0.3122281
#> ..........60 Tested: 523 Avg. Selected: 157.15 Min Tests: 1 Max Tests: 14 Mean Tests: 6.080306 . MAD: 0.3149674
#> ..........70 Tested: 523 Avg. Selected: 157.2 Min Tests: 1 Max Tests: 16 Mean Tests: 7.09369 . MAD: 0.3155163
#> ..........80 Tested: 523 Avg. Selected: 157.2625 Min Tests: 2 Max Tests: 19 Mean Tests: 8.107075 . MAD: 0.3155763
#> ..........90 Tested: 523 Avg. Selected: 157.0556 Min Tests: 2 Max Tests: 19 Mean Tests: 9.120459 . MAD: 0.3156714
#> ..........100 Tested: 523 Avg. Selected: 157.23 Min Tests: 2 Max Tests: 20 Mean Tests: 10.13384 . MAD: 0.3157428
LASSO
cvLASSO <- randomCV(MelanomaSeborrheic,"Class",
LASSO_MIN,
trainSampleSets=cvKNN$trainSamplesSets,
featureSelectionFunction = cvKNN$selectedFeaturesSet,
)
#> ..........10 Tested: 342 Avg. Selected: 42.5 Min Tests: 1 Max Tests: 4 Mean Tests: 1.549708 . MAD: 0.4261405
#> ..........20 Tested: 459 Avg. Selected: 38.35 Min Tests: 1 Max Tests: 6 Mean Tests: 2.309368 . MAD: 0.428814
#> ..........30 Tested: 504 Avg. Selected: 37.56667 Min Tests: 1 Max Tests: 9 Mean Tests: 3.154762 . MAD: 0.4280326
#> ..........40 Tested: 515 Avg. Selected: 38.6 Min Tests: 1 Max Tests: 10 Mean Tests: 4.116505 . MAD: 0.4298079
#> ..........50 Tested: 520 Avg. Selected: 38.62 Min Tests: 1 Max Tests: 12 Mean Tests: 5.096154 . MAD: 0.4294858
#> ..........60 Tested: 523 Avg. Selected: 38.71667 Min Tests: 1 Max Tests: 14 Mean Tests: 6.080306 . MAD: 0.4307832
#> ..........70 Tested: 523 Avg. Selected: 38.44286 Min Tests: 1 Max Tests: 16 Mean Tests: 7.09369 . MAD: 0.4309233
#> ..........80 Tested: 523 Avg. Selected: 37.2 Min Tests: 2 Max Tests: 19 Mean Tests: 8.107075 . MAD: 0.4309021
#> ..........90 Tested: 523 Avg. Selected: 37.54444 Min Tests: 2 Max Tests: 19 Mean Tests: 9.120459 . MAD: 0.4311408
#> ..........100 Tested: 523 Avg. Selected: 38.1 Min Tests: 2 Max Tests: 20 Mean Tests: 10.13384 . MAD: 0.4312076