当前位置: 首页 > news >正文

SCS 59.单细胞空间转录组空间度量(SPATA2)


Spatial Measures

介绍

空间转录组学和图像分析领域中,研究人员试图回答的许多问题都与空间相关。观测值的坐标通常会缩放到当前使用的图像分辨率。以Visium平台为例,如果将10X Visium输出中的tissue_lowres_image.png替换为tissue_hires_image.png,条形码斑点的坐标会相应缩放,以确保坐标与图像保持对齐。因此,坐标可用于回答相对空间问题,但不能用于绝对度量。例如,“坏死区域的面积约为400像素”这一说法是没有意义的。如果以像素为单位,面积将始终取决于图像分辨率。本教程将解释SPATA2如何通过像素比例因子计算Visium平台从像素到SI单位的转换,并提供关于如何利用SI距离进行工作的示例。

library(SPATA2) library(tidyverse)
# load SPATA2 inbuilt example data (and rename an image for this tutorial) object_t275 <- loadExampleObject("UKF275T") %>% renameImage(img_name = "image1", new_img_name = "lowres")
text_size <- theme(text = element_text(size = 17.5)) plotImage(object_t275, img_name = "lowres") + text_size + labs(subtitle = "Normal resolution")

# very_low_res image has been registered using `registerImage()` plotImage(object_t275, img_name = "very_low_res") + text_size + labs(subtitle = "Very low resolution")

2. 像素比例因子

要以绝对数值回答问题,必须将距离转换为国际单位制(SI)单位,即微米、毫米、厘米等。这是可能的,因为大多数空间组学研究都带有真实值。

2.1 Visium

在10X Visium的情况下,此真实值是两个相邻条形码点之间的中心到中心距离,该距离始终为100微米。利用此信息,可通过像素比例因子计算实际距离和面积。该比例因子由initiateSpataObjectVisium()自动计算。(如果您在SPATA2对象中注册了多张图像,请注意,默认情况下会使用活动图像的像素比例因子。)

# how many um is one pixel in side lengths getPixelScaleFactor(object_t275, unit = "um")
## [1] 13.68328 ## attr(,"unit") ## [1] "um/px"
# how many pixel is one um in side lengths getPixelScaleFactor(object_t275, unit = "um", switch = TRUE)
## [1] 0.07308187 ## attr(,"unit") ## [1] "px/um"
# by default the pixel scale factor of the active image is used getImageNames(object_t275)
## [1] "lowres" "very_low_res"
# which is image 'lowres' in this example activeImage(object_t275)
## [1] "lowres"
# how many um is one pixel in side lengths in case of an even lower resolution? getPixelScaleFactor(object_t275, unit = "um", img_name = "very_low_res")
## [1] 78.94202 ## attr(,"unit") ## [1] "um/px"

2.2 MERFISH and Co

像素比例因子这一术语源于SPATA2最初仅被认为适用于Visium数据集的时期。后来,其应用范围已扩展到其他平台,例如MERFISH,该平台提供以微米为单位的细胞坐标。如果平台提供的观测坐标单位为国际单位制(SI)单位,则理论上不需要像素比例因子。但为了使SPATA2代码正常运行,SPATA2object中必须存在该比例因子。因此,它会由相应的initiateSpataObject*()函数自动设置。例如,在MERFISH数据中,x坐标和y坐标以微米(um)为单位提供。因此,通过initiateSpataObjectMERFISH()函数初始化的SPATA2对象的像素比例因子始终为1毫米/像素。

3. 距离的运用

多个函数的参数以某种方式涉及距离度量。SPATA2 使用 units 包来处理距离。除非文档中有其他说明,否则可以将距离以像素或 SI 单位提供。在后台,输入会被转换为像素并与当前分辨率对齐。4.1 距离转换部分给出了如何进行此操作的一些示例。

3.1 处理距离输入和输出

validUnitsOfLength()
## nanometer micrometer millimeter centimeter decimeter meter pixel ## "nm" "um" "mm" "cm" "dm" "m" "px"
# wrappers around units::set_units() as_micrometer(input = "4mm")
## 4000 [um]
as_millimeter(input = "4cm")
## 40 [mm]
### convert from si -> pixel # example 1: a simple string works as_pixel(input = "4mm", object = object_t275)
## [1] 292.3275 ## attr(,"unit") ## [1] "px"
# example 2: a unit object works, too unit_input <- units::set_units(x = 4, value = "mm") unit_input
## 4 [mm]
class(unit_input)
## [1] "units"
as_pixel(input = unit_input, object = object_t275)
## [1] 292.3275 ## attr(,"unit") ## [1] "px"
### convert from pixel -> si # example 1: simple numeric input is interpreted as pixel as_millimeter( input = c(100, 200, 300), object = object_t275 )
## Units: [mm] ## [1] 1.368328 2.736657 4.104985
# example 2: strings with px suffix work, too as_micrometer( input = c("50px", "200px", "800px"), object = object_t275 )
## Units: [um] ## [1] 684.1642 2736.6568 10946.6271

3.2 Examples

以下是一些实际距离可能发挥作用的例子。

# specifying x- and y-range while handling images xrange = c("2.5mm", "6.5mm") yrange = c("0.5mm", "4.5mm") # where to set the breaks is a measure of distance, too breaks <- str_c(0:8, "mm") # vector of valid distance inputs print(breaks)
## [1] "0mm" "1mm" "2mm" "3mm" "4mm" "5mm" "6mm" "7mm" "8mm"
axes_add_on <- ggpLayerAxesSI(object_t275, unit = "mm", breaks = breaks) rect_add_on <- ggpLayerRect( object = object_t275, xrange = xrange, yrange = yrange ) plotImage(object = object_t275) + rect_add_on + axes_add_on + text_size

plotImage( object = object_t275, xrange = xrange, # crop the image with distance input yrange = yrange # crop the image with distance input ) + text_size

plotImage(object_t275) + ggpLayerAxesSI(object_t275, unit = "mm", breaks = breaks) + ggpLayerSpatAnnOutline(object_t275, ids = "img_ann_1", fill = "orange") + ggpLayerHorizonSAS(object_t275, id = "img_ann_1", distance = "1mm") + ggpLayerScaleBarSI(object_t275, sb_dist = "1mm", sb_pos = c("5.5mm", "7.5mm"), text_size = 15, text_nudge_y = 10) + text_size

4. 与区域相关的工作

除了距离之外,还可以计算面积。这在例如图像注释的面积与生物学问题相关时会变得有趣。

4.1 处理区域输入和输出

validUnitsOfArea()
## [1] "nm2" "um2" "mm2" "cm2" "dm2" "m2" "px"
validUnitsOfAreaSI()
## [1] "nm2" "um2" "mm2" "cm2" "dm2" "m2"
getPixelScaleFactor(object_t275, unit = "um2", img_name = "lowres")
## [1] 187.2323 ## attr(,"unit") ## [1] "um2/px"
# more um2 per pixel in the very low resolution image # -> pixels are smaller getPixelScaleFactor(object_t275, unit = "um2", img_name = "very_low_res")
## [1] 6231.843 ## attr(,"unit") ## [1] "um2/px"
# numeric input is interpreted as pixel as_millimeter2(input = c(200, 400, 4000, 50000), object = object_t275)
## Units: [mm^2] ## [1] 0.03744645 0.07489290 0.74892903 9.36161289
# if character, different units can be specified as input as_centimeter2(input = c("4mm2", "400px"), object = object_t275)
## Units: [cm^2] ## [1] 0.040000000 0.000748929

4.2 Examples

# process the diet example object object_t313 <- identifyTissueOutline(example_data$object_UKF313T_diet)
# set ids of example spatial annotations ids <- c("necrotic_area", "necrotic_edge", "necrotic_edge2") plotSpatialAnnotations(object_t313, ids = ids, nrow = 1)

# process the diet example object object_mouse <- loadExampleObject("LMU_MCI") object_mouse <- identifyTissueOutline(object_mouse)
# get tissue area by tisse section getTissueArea(object_mouse, unit = "mm2")
## Units: [mm^2] ## tissue_section_1 tissue_section_2 ## 6.349445 7.945489
getTissueArea(object_t313, unit = "mm2")
## 29.67623 [mm^2]
# left plotImage(object_t313, unit = "mm") + ggpLayerTissueOutline(object_t313)

# right plotImage(object_mouse, unit = "mm") + ggpLayerTissueOutline(object_mouse)

# use the three necrotic ids from above spat_ann_areas <- getSpatAnnArea(object = object_t313, ids = ids, unit = "mm2") print(spat_ann_areas)
## Units: [mm^2] ## necrotic_area necrotic_edge necrotic_edge2 ## 6.1849516 0.4618869 0.6252351
threshold <- units::set_units(x = 1, value = "mm2") # keep only those with an area smaller than 1mm2 print(spat_ann_areas[spat_ann_areas < threshold])
## Units: [mm^2] ## necrotic_edge necrotic_edge2 ## 0.4618869 0.6252351
http://www.cnnetsun.cn/news/74681.html

相关文章:

  • 【毕业设计】基于springboot高校体育运动会比赛系统运动项目、运动论坛(源码+文档+远程调试,全bao定制等)
  • 干货收藏:AI大模型进化史,从ChatGPT到智能体的三次关键跃迁
  • Docker Compose编排LLama-Factory多节点训练集群详细配置示例
  • Wan2.2-T2V-A14B模型部署指南:从VSCode配置C/C++环境说起
  • 计算机Java毕设实战-基于springboot公寓管理系统基于Springboot的公寓报修管理系统【完整源码+LW+部署说明+演示视频,全bao一条龙等】
  • 如何制作支持离线地图的GPS自行车码表:从硬件选型到功能实现的完整指南
  • 计算机Java毕设实战-基于springboot国风彩妆网站springboot国风彩妆化妆品网站电商销售商城系统【完整源码+LW+部署说明+演示视频,全bao一条龙等】
  • Honey Select 2 HF Patch技术架构深度解析与模块化部署指南
  • 【课程设计/毕业设计】基于springboot的自习室预订系统设计与实现基于springboot高校自习室预约系统的设计与实现【附源码、数据库、万字文档】
  • 大学计算机基础系列(合集)
  • 【课程设计/毕业设计】基于Web的高校大学生奖学金评定系统设计与实现基于springboot高校学生奖学金评定系统的设计与实现【附源码、数据库、万字文档】
  • 【爬虫框架-8】其他
  • Vue-next-admin终极指南:打造现代化后台管理系统的完整解决方案
  • vgmstream终极指南:游戏音频转换与播放全攻略
  • vgmstream音频解码神器:游戏音频格式转换终极指南
  • 印象大红袍通过上市聆讯:上半年营收5588万 利润678万
  • 蔡东青创办的奥动冲刺港股:靠换电半年营收3.2亿同比降32% 亏1.57亿 蔚来资本是股东
  • 基于Next.js的LobeChat为何成为GitHub星标项目?技术架构全拆解
  • 广合科技冲刺港股:前9个月营收38亿净利7亿 刚斥资3.2亿买楼
  • Vue Signature Pad电子签名组件完整使用指南:快速集成步骤与实用配置技巧
  • Joy-Con Toolkit终极指南:如何轻松自定义你的游戏手柄
  • 暗黑破坏神II存档编辑器:多版本兼容的角色定制解决方案
  • [自动化办公] 【Python】【低代码】在明道云中实现无需 pandas 的数据聚合与 HTML 表格生成技巧
  • OpenFace完整指南:从零开始掌握面部行为分析终极工具
  • Python协同过滤算法 音乐推荐系统_731w447o 论坛 浏览历史
  • 17、图像深度处理技术:从理论到实践
  • GitHub项目Star暴涨:Stable Diffusion 3.5 FP8成AIGC开发者新宠
  • Windows显示器亮度控制终极方案:Twinkle Tray完整使用手册
  • VideoDownloadHelper 终极使用指南:轻松下载网页视频资源
  • 高效STL转STEP工具:3D格式转换的完整解决方案