Studying the structure of so-called real networks, that is networks obtained from sociological or biological data for instance, has become a major field of interest in the last decade. One way to deal with it is to consider that networks are partially built from small functional units called motifs, which can be found by looking for small subgraphs whose numbers of occurrences in the whole network are surprisingly high. In this article, we propose to define motifs through a local over-representation in the network and develop a statistic to detect them without relying on simulations. We then illustrate the performance of our procedure on simulated and real data, recovering already known biologically relevant motifs. Moreover, we explain how our method gives some information about the respective roles of the vertices in a motif. Detecting local network motifs 909 among all graphs having the same degree distribution as the network of interest. The stub-rewiring algorithm introduced by Milo et al. (2002) is used to sample under this model in several methods for motif detection, including those of Kashani et al. (2009); Kashtan et al. (2004); Wernicke and Rasche (2006), the method based on graph alignments of Berg and Lässig (2004) and the method devoted to labeled graphs of Banks et al. (2008). The earliest implementation of this method by Kashtan et al. (2004) was incorrect as the sampling was nonuniform (Wernicke and Rasche, 2006) but it was subsequently corrected. However, Artzy-Randrup et al. (2004) point out that it does not take into account the preferential links between some vertices and the high local density, which are two major features of biological networks. They show on a toy-example that the use of the stub-rewiring model and of a Z-score to detect motifs selects over-represented patterns in randomly chosen networks when the null model generates spatially clustered networks.Another way to define the null model is to consider a random graph model defined by a probability distribution. Literature about random graph models and their suitability to real networks is abundant (see e.g. Chung and Lu, 2006). Exponential family models have been developed to take the counting of small subgraphs into account (Holland and Leinhardt, 1970;Hunter and Handcock, 2006), but simulations are needed to compute normalization constants and the law of the motif counts seems to be analytically untractable. Another widely studied family of models are block models, which allow different link probabilities between classes of vertices and thus model the heterogeneity of connection patterns. Moreover, Picard et al. (2008) show that mean and variance calculation for the pattern counts are tractable under such models.Whatever the choice of the null model, the exact distributions of subgraph counts are unknown. Most of the detection algorithms assume a normal distribution and use the Z-score to compute p-values. However, Janson (1990) show that even asymptotically this assumption can be wrong. In the case of mixture models, Picard e...