library(CardinalWorkflows)
data(pig206, pig206_analyses)
pData(pig206)$myclusters <-pig206.sscg[[r=2,s=6,k=20]]$classes
write.csv(pData(pig206),file="pixeldata.csv")library(CardinalWorkflows)
data(pig206, pig206_analyses)pData(pig206)$myclusters <- pig206.sscg[[r=2,s=6,k=20]]$classeswrite.csv(pData(pig206), file="pixeldata.csv")##kidney_sa: original data##kidney_sa.peaks : peakdata
##segmentation:sscg_sa <- spatialShrunkenCentroids(kidney_sa.peaks,r=1,k=10,s=1)
##plot spectra by SSCG class:plot(kidney_sa,pixel=1:ncol(kidney_sa),pixel.groups=sscg_sa$classes[[1]],fun=mean)featureApply(kidney_sa,.pixel.groups=sscg_sa$classes[[1]],.fun=mean)
##need the MALDIquant package:
require(MALDIquant)require(MALDIquantForeign)
##get mean cluster data as data.frame:
mean_df <- data.frame(featureApply(kidney_sa,.pixel.groups=sscg_sa$classes[[1]],.fun=mean))
##coerce mean specs to MALDIquant:
SegmentsMzMls <- lapply(c(1:sscg_sa$k[[1]]),function(x){ spec <-createMassSpectrum(mass=mz(kidney_sa.peaks), intensity=as.numeric(mean_df[x,])) return(spec)})
##write MzMl..
exportMzMl(SegmentsMzMls[[1]], file="segment_1_meanspec.mzml")
##write all MzMl via for loop..
for (i in 1:sscg_sa$k[[1]]){ exportMzMl(SegmentsMzMls[[i]], file=paste0("segment_",i,"_meanspec.mzml"))}
Hello everyone,
After performing segmentation using Spatial Shrunken Centroids (SSC), I would like to extract the value of a specific m/z for each pixel within the clusters just to compare different clusters and make statements such as "this m/z signal is 10 times more higher in cluster 1 than in cluster 2." I believe the lines of code above worked in previous versions of Cardinal, but they no longer seem to be compatible with the current version. Can anyone provide assistance on how to achieve this with the latest version of Cardinal?
Thank you!