UseMethod(generic = “FindMarkers“, object = object)获取FindMarkers的源代码

今天在使用Seurat包的时候,想看看Findmarker的源代码写了什么,于是用了

getAnywhere(FindMarkers)

来查看源代码,但是却反回了:

A single object matching ‘FindMarkers’ was found
It was found in the following places
  package:Seurat
  namespace:Seurat
with value

function (object, ...) 
{
    UseMethod(generic = "FindMarkers", object = object)
}
<bytecode: 0x1185eaf0>
<environment: namespace:Seurat>

没有具体显示Findmarker的内容。

以下是解决办法:

FindMarkers是一个泛型函数,需要找到适用于特定对象类型的方法。

使用getMethod函数获取特定方法的实现,然后查看其源代码。

# 列出FindMarkers泛型函数的所有方法
methods("FindMarkers")
# [1] FindMarkers.Assay*    FindMarkers.default*  FindMarkers.DimReduc* 
# FindMarkers.SCTAssay* FindMarkers.Seurat*  
# see '?methods' for accessing help and source code

这将显示所有可用的FindMarkers函数的方法。

一旦确定了特定方法,就可以使用getMethod来查看其源代码。例如,如果使用的是Seurat对象:

# 获取Seurat类的特定方法
method <- getMethod("FindMarkers", "Seurat")

# 打印方法的源代码
print(method)

或者:

getAnywhere(FindMarkers.Seurat)

最终得到结果:

A single object matching ‘FindMarkers.Seurat’ was found
It was found in the following places
  registered S3 method for FindMarkers from namespace Seurat
  namespace:Seurat
with value

function (object, ident.1 = NULL, ident.2 = NULL, group.by = NULL, 
    subset.ident = NULL, assay = NULL, slot = "data", reduction = NULL, 
    features = NULL, logfc.threshold = 0.25, test.use = "wilcox", 
    min.pct = 0.1, min.diff.pct = -Inf, verbose = TRUE, only.pos = FALSE, 
    max.cells.per.ident = Inf, random.seed = 1, latent.vars = NULL, 
    min.cells.feature = 3, min.cells.group = 3, mean.fxn = NULL, 
    fc.name = NULL, base = 2, densify = FALSE, ...) 
{
    if (!is.null(x = group.by)) {
        if (!is.null(x = subset.ident)) {
            object <- subset(x = object, idents = subset.ident)
        }
        Idents(object = object) <- group.by
    }
    if (!is.null(x = assay) && !is.null(x = reduction)) {
        stop("Please only specify either assay or reduction.")
    }
    if (length(x = ident.1) == 0) {
        stop("At least 1 ident must be specified in `ident.1`")
    }
    if (is.null(x = reduction)) {
        assay <- assay %||% DefaultAssay(object = object)
        data.use <- object[[assay]]
        cellnames.use <- colnames(x = data.use)
    }
    else {
        data.use <- object[[reduction]]
        cellnames.use <- rownames(x = data.use)
    }
    cells <- IdentsToCells(object = object, ident.1 = ident.1, 
        ident.2 = ident.2, cellnames.use = cellnames.use)
    if (!is.null(x = latent.vars)) {
        latent.vars <- FetchData(object = object, vars = latent.vars, 
            cells = c(cells$cells.1, cells$cells.2))
    }
    norm.command <- paste0("NormalizeData.", assay)
    norm.method <- if (norm.command %in% Command(object = object) && 
        is.null(x = reduction)) {
        Command(object = object, command = norm.command, value = "normalization.method")
    }
    else if (length(x = intersect(x = c("FindIntegrationAnchors", 
        "FindTransferAnchors"), y = Command(object = object)))) {
        command <- intersect(x = c("FindIntegrationAnchors", 
            "FindTransferAnchors"), y = Command(object = object))[1]
        Command(object = object, command = command, value = "normalization.method")
    }
    else {
        NULL
    }
    de.results <- FindMarkers(object = data.use, slot = slot, 
        cells.1 = cells$cells.1, cells.2 = cells$cells.2, features = features, 
        logfc.threshold = logfc.threshold, test.use = test.use, 
        min.pct = min.pct, min.diff.pct = min.diff.pct, verbose = verbose, 
        only.pos = only.pos, max.cells.per.ident = max.cells.per.ident, 
        random.seed = random.seed, latent.vars = latent.vars, 
        min.cells.feature = min.cells.feature, min.cells.group = min.cells.group, 
        mean.fxn = mean.fxn, base = base, fc.name = fc.name, 
        densify = densify, norm.method = norm.method, ...)
    return(de.results)
}
<bytecode: 0xc38b748>
<environment: namespace:Seurat>

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
如果您在将List绑定到List控件时遇到了错误,可能是因为List控件无法直接将List作为数据源。您可以尝试使用BindingSource作为中间层来实现数据绑定。以下是修改后的代码示例: ```csharp using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Windows.Forms; namespace ListExample { public partial class MainForm : Form { private string connectionString = "YourConnectionString"; // 替换为您的数据库连接字符串 public MainForm() { InitializeComponent(); } private void MainForm_Load(object sender, EventArgs e) { LoadData(); } private void LoadData() { // 创建连接对象 using (SqlConnection connection = new SqlConnection(connectionString)) { // 创建查询语句 string query = "SELECT * FROM YourTableName"; // 替换为您的表名 // 打开数据库连接 connection.Open(); // 创建Command对象 SqlCommand command = new SqlCommand(query, connection); // 执行查询并获取DataReader对象 SqlDataReader reader = command.ExecuteReader(); // 创建一个List来存储数据 List<string> dataList = new List<string>(); // 读取数据并添加到List中 while (reader.Read()) { string data = reader["ColumnName"].ToString(); // 替换为您的列名 dataList.Add(data); } // 关闭DataReader reader.Close(); // 创建BindingSource对象,并将List作为数据源 BindingSource bindingSource = new BindingSource(); bindingSource.DataSource = dataList; // 将BindingSource绑定到List控件 listBox.DataSource = bindingSource; } } } } ``` 在这个示例中,我们使用了BindingSource作为中间层来将List作为数据源绑定到List控件。这样就可以解决直接将List绑定到List控件时的错误。如果问题仍然存在,请提供具体的错误信息,以便我能够更好地帮助您解决问题。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值