Skip to content

Commit

Permalink
Change cluster assignment step from cbind to $ for minor speedup
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-l-kong committed Apr 22, 2021
1 parent bbe6f63 commit 9c11720
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions ark/phenotyping/consensus_cluster.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ hClust <- consensusClusterResults[[maxK]]$consensusClass
names(hClust) <- clusterAvgs$cluster

# append hClust to each fov's data
print('Writing consensus clustering results')
print("Writing consensus clustering results")
for (i in 1:length(fovs)) {
# read in pixel data, we'll need the cluster column for mapping
fileName <- file.path(fovs[i], "feather", fsep=".")
matPath <- file.path(pixelClusterDir, fileName)
fovPixelData <- arrow::read_feather(matPath)

# assign hierarchical cluster labels
fovPixelData <- cbind(fovPixelData, hCluster_cap=hClust[as.character(fovPixelData$cluster)])
fovPixelData$hCluster_cap <- hClust[as.character(fovPixelData$cluster)]

# write consensus clustered data
clusterPath <- file.path(pixelMatConsensus, fileName)
Expand Down
2 changes: 1 addition & 1 deletion ark/phenotyping/run_trained_som.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ for (i in 1:length(fovs)) {
clusters <- FlowSOM:::MapDataToCodes(somWeights, as.matrix(fovPixelData[, markers]))

# assign cluster labels column to pixel data
fovPixelData <- cbind(fovPixelData, cluster=clusters[,1])
fovPixelData$cluster <- clusters[,1]

# write to feather
clusterPath <- file.path(pixelClusterDir, fileName)
Expand Down

0 comments on commit 9c11720

Please sign in to comment.